Create APIs
-
Create API application. API applications map API requests to InfoLink applications. Go to the home page and click Settings tab. Scroll to the API Applications section. Click + Add API app. Enter the name of the API app. The name will be used as the first top subdirectory of API endpoints. Select an application to which the API endpoints will be routed. You can use the API Applications section to view, edit, and delete API applications
-
Create API service. Go to an application -> Specifications -> right-click on API and select Create API -> enter the name of the API. This name will be used as the second top subdirectore of API endpoints.
-
Create API endpoints. Click on the API created at the previous step -> click Add endpoint. Enter endpoint properties:
-
URL: This URL is expected as tail to
<API app name>/<API service name>/. For example, if you enter “v1/party”, then the full endpoint URL will be:<API app name>/<API service name>/v1/party. Notice that the URL should start without leading slash. If you have several versons of the API service or particular endpoints, add the version as subdirectory to the URL. -
Method: Select a method such as get, post, put, delete, patch.
-
Scenario: Select a scenario that will be executed when the API endpoint is called.
-
Map request: It is a Javascript that must end with a return statement returning an object that have the following properties:
-
parameterscontains an object with the parameters of the scenario to be executed. -
datacontains an array with data passed to the scenario to be executed.
In the script you can refer to the HTTP request parameters and application variables using
$ilvariable:-
$il.request.parameters- object that contains the URL parameters of the request. -
$il.request.headers- object that contains the headers of the request. -
$il.request.body- array/object that contains the body of the request. -
$il.variables- object that contains the application variables.
-
-
Map response: It is a Javascript that must end with a return statement returning an object that have the following properties:
-
statusCode- integer that is the status code of the HTTP response. 200 by default. -
headers- object with headers to add to the HTTP response. -
body- array/object that is the body of the HTTP response.
In the script you can refer to the results of scenario execution using
$ilvariable:-
$il.status-"success"in case of successful scenario execution;"error"in case of an error in the scenario execution. If there is an error:$il.result.errorCodecontains the error code;$il.result.errorMessagecontains the error message;$il.result.errorStackTracecontains a formatted string of the error stack trace. -
$il.data- data returned by the scenario.
-
-