Calling APIs

APIs that are exposed through the API Platform console can be called from recipes in accounts other than one owning the recipe, as well as from third-party tools, programs, and scripts. The API manager must provide the Auth Token or JWT token value to the client in order to call any endpoints in an API Collection.

Authorization Headers

If the Access Profile specifies the Auth Token method of authentication, then the Auth Token value must be passed by the client as the value of the API-Token header. If the authorization method is JSON Web Token, then the value of the encoded and signed token is passed in the Authorization header, using the Bearer scheme.

Calling an API Endpoint from a Recipe

An API Endpoint that belongs to another user can be called from a recipe using the HTTP Connector. Select the Send request action of the Connector. The following screen shows a typical configuration for this action (in this case a POST request):

API Client Request API Client Request

Make sure that the type of request (POST, PUT, GET) matches the API that you are calling. Any required fields need to be specified in the body (for POST and PUT) or as query parameters in the URL (for GET).

Also, note that an API-Token request header has been added. Its value should be set to the token that the API owner has supplied to you. (This assumes the Auth Token method of authentication)

Caution The API token should not be shared with other users. Therefore it is not recommended to make a recipe public that contains such a token.

Testing a Call to an API

Using the recipe test feature, you can run the recipe a single time and have it generate a call to the REST API. If successful, the API will return a 200 status and the recipe execution will continue to completion. There are several possible errors that can occur. Here are some of the common ones.

Error code Description Details
500 Internal error This usually indicates that the request parameters were missing or invalid for the API.
401 Unauthorized This indicates a problem with the API token. It is missing or does not match the correct code for the API you are trying to call.
404 Not found This may indicate that you have the incorrect URL in the request configuration on your side. Another possible cause is that the recipe you are calling is not running. Yet another possibility is that the recipe owner has either the API Collection or your client configuration set to Disabled.

Calling the API from other clients

Clients can access the Open API description for the service by performing a GET request on the API URL and adding /swagger to the path. This URL should also have the API token as a query parameter. So for example, if the API URL is https://workato.com/doc/service/sales-api-v1, the Open API description is available at a URL like:

https://workato.com/doc/service/sales-api-v1/swagger?token=e6883d64843aaed62d48bcdf3cf4ebbf

The Open API description can be used by tools such as the Swagger UI to make requests. For programmers, it is possible to generate API client code using Swagger Codegen.

Any other standard HTTP request tool, such as the command-line tool cURL or the popular open source tool Postman, can be used to make requests.

results matching ""

    No results matching ""