Calling REST Endpoints
The REST Execution Method lets a JAMS Job call a REST endpoint directly. You build the request on the Job's Source tab: the method, URL, headers, and body. JAMS sends one request and sets the Job's final status from the HTTP status code the endpoint returns.
A REST Connection holds what many Jobs share: the base URL, a default timeout, default headers, and how requests are authorized. Credentials, tokens, and secrets are stored in a JAMS Credential that the Connection references. You never enter them on the Job itself.
REST Jobs and REST Connections are created and edited in the JAMS Web Client only. In the JAMS Desktop Client, the Source tab of a REST Job shows the message "REST jobs are defined in the JAMS Web Client" instead of the request, and REST is not offered as a Connection Type.
Before You Begin
- If the endpoint requires authorization, create a JAMS Credential that holds the secret. See Credentials for more information. What goes in the Credential depends on the Authorization Profile:
| Authorization Profile | Logon Username field | Password fields |
|---|---|---|
| Basic | The username. | The password. |
| API Key / Bearer Token | Not used. | The API key or token. |
| OAuth 2.0 Client Credentials | The client ID. | The client secret. |
- If several Jobs call the same service, create a REST Connection for it. A Job can also call a public endpoint with no Connection by entering a full URL.
Adding a REST Connection
- Click Environment in the left sidebar.
- Click Connections.
- Click Add.
- In the Connection Name field, enter a name for the connection.
- In the Connection Type field, select REST.
- Click Save & Continue.
- Click the Properties tab.
- Set the properties described in the tables below.
- Click Save.
REST Properties
| Property | Description |
|---|---|
| Base URL | The address that a Job's URL is added to, such as https://api.example.com/v1. Any path in the base URL is kept. Leave it empty to require every Job to enter a full URL. |
| Timeout | The default time, in seconds, to wait for a response. The default is 100. A Job can override it. The timeout applies to each call separately, so a Job that uses OAuth 2.0 Client Credentials can wait up to twice this long: once for the token and once for the request. |
| Default Headers | Headers sent with every request that uses this Connection. Click Add to add a row, then enter the Name and Value. If a Job sets a header with the same name, the Job's header is used instead. Header names are not case sensitive. |
REST Authorization Properties
Select an Authorization Profile. The fields shown below it depend on the profile you select. When you change profiles, the fields used only by the previous profile are cleared.
| Property | Profiles | Description |
|---|---|---|
| Authorization Profile | All | How requests are authorized: None, Basic, API Key / Bearer Token, or OAuth 2.0 Client Credentials. |
| Credential | Basic, API Key / Bearer Token, OAuth 2.0 Client Credentials | The JAMS Credential that holds the secret. Required for these profiles. |
| Authorization Header Name | API Key / Bearer Token | The header the key is sent in. The default is Authorization. Change it for services that expect another header, such as X-API-Key. |
| Authorization Value Prefix | API Key / Bearer Token | Text placed in front of the key, used exactly as entered. The default is Bearer with a trailing space, which separates it from the key. Leave it empty to send the key on its own. |
| Token URL | OAuth 2.0 Client Credentials | The endpoint JAMS requests an access token from. Required for this profile. |
| Scope | OAuth 2.0 Client Credentials | The scope requested with the token, sent exactly as entered. Separate multiple scopes with spaces. A comma is not a separator. |
| Additional Token Parameters | OAuth 2.0 Client Credentials | Extra name and value pairs sent with the token request, for services that require a parameter such as audience or resource. |
The authorization header is applied last. It replaces any header with the same name entered on the Connection or the Job.
For OAuth 2.0 Client Credentials, JAMS sends the client ID and client secret in the body of the token request (the client_secret_post method). Token endpoints that accept only client_secret_basic are not supported.
Creating a REST Job
- Click Jobs from the main menu.
- In the Folder Navigator, select a Folder where the Job will be saved.
- Click Add to add a new Job.
- In the Job Name field, enter a name for the Job.
- In the Execution Method field, select REST.
- Click Save & Continue.
- On the Source tab, build the request using the fields described in the table below.
- Click the Schedules tab.
- As needed, schedule when the Job will run.
- Click Save.
Source Tab Fields
| Field | Description |
|---|---|
| REST Connection | The REST Connection that supplies the base URL, authorization, default headers, and default timeout. Select None / public to call an endpoint without a Connection. |
| Method | The HTTP method: GET, POST, PUT, PATCH, or DELETE. The default is GET. |
| URL | Required. If the selected Connection has a base URL, enter a path to add to it, such as /orders. The text under the field shows the base URL. If the Connection has no base URL, or no Connection is selected, enter a full address that starts with http:// or https://. A full address is always used as entered, even when the Connection has a base URL. |
| Headers | Headers sent with this request. Click Add to add a row, then enter the Name and Value. A header here replaces a Connection default header with the same name. |
| Content Type | Shown only for POST, PUT, and PATCH. The media type of the body: application/json, application/x-www-form-urlencoded, or text/plain. The default is application/json. |
| Body | Shown only for POST, PUT, and PATCH. The request body. If you change the method to GET or DELETE, the body and content type are cleared. |
| Timeout | The time, in seconds, to wait for a response. Leave it empty to use the Connection's timeout, or 100 seconds when no Connection is selected. |
Using Parameters and Variables in the Request
The URL, Headers, and Body fields accept substitution tokens. When the Job runs, JAMS replaces each token with its value:
{Name}is replaced with the value of the Job Parameter or Variable named Name.{JAMS.Property}is replaced with the value of the named JAMS property.
For example, a URL of /orders/{OrderId} with an OrderId Parameter of 1042 calls /orders/1042.
To send a literal brace instead of a token, put a backslash in front of it. Type \{ for { and \} for }. This matters most in a JSON body, where every brace would otherwise be read as a token:
\{ "orderId": "{OrderId}", "status": "shipped" \}
This sends { "orderId": "1042", "status": "shipped" }. Only a backslash immediately in front of a brace is treated as an escape. Other backslashes, such as \n in a JSON string, are sent unchanged.
How the Job Outcome is Determined
JAMS sends one request and sets the Job's final status from the response. The final status text is the HTTP status code and reason, such as 200 OK.
| Result | Job outcome |
|---|---|
| 2xx status | Completes successfully. |
| 3xx status | Completes with information. Redirects are not followed, so the 3xx response is the final answer. |
| 4xx or 5xx status | Fails. |
| The request could not be completed, for example the host was not found, the certificate was rejected, or the connection was refused | Fails. The final status shows the full chain of error messages, so the cause is visible. |
| No response within the timeout | Fails with "The request did not complete within the timeout." |
| The Job was canceled while waiting | Fails with "The request was canceled." |
A Job also fails before sending anything if its configuration is incomplete. For example, the URL is not a full address and the Connection has no base URL, or the Authorization Profile needs a Credential and none is selected, the Credential has no password, or it no longer exists.
What the Job Log Records
The Job log records:
- The method and full URL of the request, such as GET https://api.example.com/v1/orders/1042.
- Which authorization was applied: the username for Basic, the header name for API Key / Bearer Token, or the client ID for OAuth 2.0 Client Credentials. For OAuth, the token request's method and Token URL are also recorded.
- The response status code and reason, the response content type, and its size when the endpoint reports one.
- The elapsed time in milliseconds.
The Job log does not record header values, the request body, the response body, passwords, keys, client secrets, or access tokens. The response body is never read or stored.
A secret placed directly in the URL, such as ?api_key=abc123, is not masked. It appears in the Job log as part of the URL. Use the API Key / Bearer Token profile on the Connection instead, and set the Authorization Header Name to the header the service expects.