Skip to main content

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.

note

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 ProfileLogon Username fieldPassword fields
BasicThe username.The password.
API Key / Bearer TokenNot used.The API key or token.
OAuth 2.0 Client CredentialsThe 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​

  1. Click Environment in the left sidebar.
  2. Click Connections.
  3. Click Add.
  4. In the Connection Name field, enter a name for the connection.
  5. In the Connection Type field, select REST.
  6. Click Save & Continue.
  7. Click the Properties tab.
  8. Set the properties described in the tables below.
  9. Click Save.

REST Properties​

PropertyDescription
Base URLThe 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.
TimeoutThe 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 HeadersHeaders 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.

PropertyProfilesDescription
Authorization ProfileAllHow requests are authorized: None, Basic, API Key / Bearer Token, or OAuth 2.0 Client Credentials.
CredentialBasic, API Key / Bearer Token, OAuth 2.0 Client CredentialsThe JAMS Credential that holds the secret. Required for these profiles.
Authorization Header NameAPI Key / Bearer TokenThe 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 PrefixAPI Key / Bearer TokenText 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 URLOAuth 2.0 Client CredentialsThe endpoint JAMS requests an access token from. Required for this profile.
ScopeOAuth 2.0 Client CredentialsThe scope requested with the token, sent exactly as entered. Separate multiple scopes with spaces. A comma is not a separator.
Additional Token ParametersOAuth 2.0 Client CredentialsExtra 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​

  1. Click Jobs from the main menu.
  2. In the Folder Navigator, select a Folder where the Job will be saved.
  3. Click Add to add a new Job.
  4. In the Job Name field, enter a name for the Job.
  5. In the Execution Method field, select REST.
  6. Click Save & Continue.
  7. On the Source tab, build the request using the fields described in the table below.
  8. Click the Schedules tab.
  9. As needed, schedule when the Job will run.
  10. Click Save.

Source Tab Fields​

FieldDescription
REST ConnectionThe REST Connection that supplies the base URL, authorization, default headers, and default timeout. Select None / public to call an endpoint without a Connection.
MethodThe HTTP method: GET, POST, PUT, PATCH, or DELETE. The default is GET.
URLRequired. 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.
HeadersHeaders 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 TypeShown 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.
BodyShown 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.
TimeoutThe 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.

ResultJob outcome
2xx statusCompletes successfully.
3xx statusCompletes with information. Redirects are not followed, so the 3xx response is the final answer.
4xx or 5xx statusFails.
The request could not be completed, for example the host was not found, the certificate was rejected, or the connection was refusedFails. The final status shows the full chain of error messages, so the cause is visible.
No response within the timeoutFails with "The request did not complete within the timeout."
The Job was canceled while waitingFails 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.

warning

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.