How APIEngine Builds Endpoint URL - SuiteEngine/APIEngine GitHub Wiki
This Section will describe how the API Engine builds the Endpoint URL for an API Call.
URLs can be broken down into logical pieces, the SuiteEngine API Engine breaks down the API Endpoint URL into the following pieces and puts them all together.
- Base URL - https://my.baseurl.com
- Fixed Path - my/fixed/path
- Variable Path - myaccountnumber
- Query Parameters
- Tags - just a text parameter - safemode
- Key Value - Parameters that have both a key and a value component. - foo=bar
Put them all together and you have a endpoint url: https://my.baseurl.com/my/fixed/path/myaccountnumber?safemode&foo=bar
For a new API Message where the Query Request is empty, the API Engine takes the following steps to build the Endpoint URL
- Determine the value of the base url, this normally comes from the selected API Credential Record, unless there is an URL Override API variable associated with the API Function, then its value is used.
- Next, if the API Function has a value for the Static Path value, a / and the Static Path value is appended to the base url.
- Then, if the API Function has API Variables of type URL Path, they are added sequentially to the url in auto build sequence order. Slashes are added automatically where appropriate.
- Finally, if the API Function has API Variables of type URL Parameter, a ? is appended to the url and URL Parameter records are added sequentially to the url in auto build sequence order. The ampersand (&) character is added automatically in between multiple parameters. Note that key value query parameters use Variable Value type Key Value Text, and Tag parameters use Variable Value type Text Value.
If you are re-executing an API Message that already has a Query Request defined, then that Query Request stored on the message is used and the API Endpoint url.
Technical Note: As of this writing, there are 2 published events that allow developers to create or modify the endpoint url via extension code.
SENAPIRequestProcessingEvent.OnBeforeGetURL(SENAPIFunction, SENAPIMessage, BaseURL, URLText, IsHandled);
SENAPIRequestProcessingEvent.OnAfterGetURL(SENAPIFunction, SENAPIMessage, BaseURL, URLText);