Search

Home

Home

Configuration and Invocation of the REST API – Service Address (Endpoint) Configuration and Construction

Configuration and Invocation of the REST API – Service Address (Endpoint) Configuration and Construction

The GRAVITY platform provides a server that handles REST API requests. All triggers defined as Web Service are exposed as services and can be used by any external software as an API, with functionality defined in the project. Invoking the API requires knowledge of the service endpoint, specification of the HTTP method, performing authorization, and providing input data—either as a defined JSON object in the request body (POST) or as query parameters (GET).

Service endpoint configuration and construction

The service is available in two ways:

  • via a common endpoint for all services (the trigger to be executed is determined by the call_alias field in the request body):
  • [address configured in the Options menu]/callandgetdata

    e.g. http://localhost:9010/GravityApi/callandgetdata

  • as an endpoint built based on the Alias field defined in the trigger configuration:
  • [address configured in the Options menu]/v1/[alias]

    e.g. http://localhost:9010/GravityApi/v1/articles

Invocation methods

For the common (aggregate) endpoint, the only supported way to invoke the service is the POST method.

For endpoints built based on the trigger alias, both POST and GET methods are supported. In a GET request, all parameters required to invoke the API must be provided as URL query parameters. In a POST request, parameters can be included in the request body, either by using the "content-type": "application/json" header or by sending form data with "content-type": "x-www-form-urlencoded"

Authorization

Depending on the configuration selected in the Options tab of the GRAVITY application, the Authorization header uses either Basic or Bearer authentication.

For example: “Authorization” : “Bearer [token generated for the permission]” or “Authorization”: “Basic [Base64 (user:pass)]”

Body

The GRAVITY application requires a standardized request to be provided either as a JSON object in the request body or as parameters, depending on the invocation method.

An example service invocation is shown in the chapter REST API invocation and response.

Invocation result

The GRAVITY server returns an appropriate StatusCode depending on the result of executing the triggered process.

Possible returned status codes:

200 – the project invoked by the trigger completed successfully.

400 – invalid invocation; no trigger exists with the specified alias.

401 – invalid user or authorization type.

500 – an error occurred in the project.