Rest API definition

Response definition

The API supports ONLY REST services that return the type application/json .

The default ContentType with which we send requests to the service is application/json. Also supported is multipart/form-data, if the header contains the parameter {'Content-Type': 'multipart/form-data'}. For example:

api.rest.v1.get('serviceId', {queryParams: {'key': 'value'}}, {'Content-Type': 'multipart/form-data'});

The response from the service looks as follows:

{
    status: {
        code: int,
        message: String
    },
    headers: Map<String, String>,
    body: Map<String, Object>
}

All elements in the response are processed as native variables in JavaScript. They can be accessed, for example, like this:

response.status.code   // <--- obtaining the value from the `code` field, containing the response code, e.g. 200
response.status.message   // <--- obtaining the value from the `message` field, containing the response message, e.g. "Accepted"
 
response.headers.language    // <---  obtaining the value of the return header named `language`
 
response.body.user.type    // <--- obtaining the value of a specific field from the response, where the response looks like: {"user": {"type": "userType"}}

Exception definition

In the case of a return code other than 2XX we will get a catchable exception. For example in a situation with code 404 (service unavailable or incorrect address), code 405 (invalid method) or code 500 (internal server error on the service side).

The exception looks like this:

To verify whether this is an exception to handle ourselves, we can check if the caught item has the fields we are interested in.

Request definition

A request can be parameterized.

Requests can contain a payload:

And they can be without a payload:

Below is the definition of parameters:

The PATH definition looks as follows:

The TIMEOUTS definition looks as follows:

Example request executions are shown in the sections below.

Requests

For each of the requests below we assume a consistent configuration:

GET

Request without payload.

Examples:

And an example ScriptService:

DELETE

Request without payload.

Examples:

And an example ScriptService:

POST

Request with payload.

Examples:

And an example ScriptService:

PUT

Request with payload.

Examples:

And an example ScriptService:

PATCH

Request with payload.

Examples:

And an example ScriptService:

Eximee Designer

API hints have been provided in Eximee Designer.

Figure 1. Hints for GET / POST/ PUT / DELETE requests.
Illustration 2. Description of the hint for a specific request (GET).

Illustration 3. View after inserting code automatically from the hint.

And hints of possible serviceIds to use at the current moment. In case of a problem fetching the current list of serviceIds, the editor continues to operate, but does not provide information about any serviceId.

Illustration 4. serviceId hint outside the character: ' and "

Illustration 5. serviceId hint limited by the character: "

Examples

"demo_api_RestTest" - executing requests with various parameters

"demo_api_exchangeRate_404" - exception handling

"demo_api_exchangeRate_validator" - example of a validator calling an external service

API testing (Postman)

Postman is a tool for testing and working with APIs that allows you to easily send HTTP requests (e.g. GET, POST) and analyze server responses. (https://www.postman.com/)

Last updated

Was this helpful?