Web Request Task
The Web Request Task was substantially enhanced beginning with adTempus 6. If you are connected to an older version of the adTempus server the new options are not available; see the Web Request Task (Legacy) topic for information about the older features.
The Web Request task allows adTempus to send an HTTP request to a Web server or Web service (API) and process the response, similar to using a tool such as curl or Postman.
The task can be used to:
- Call a REST or SOAP API, sending data in the query string or in a JSON, XML, form, or multipart body
- Upload files to a Web service
- Download a page or file from a Web server
- "Ping" a URL on a server (for example, if a Web application has processing that is triggered by requesting a special URL)
Features of the task include:
- Any HTTP method (GET, POST, PUT, PATCH, DELETE, and others)
- Query and body parameters, request headers, and a raw body, all of which may contain Job Variables
- Windows, Basic, Bearer token, and OAuth 2.0 client credentials authentication
- Secret header and parameter values (such as API keys), which are stored encrypted and masked in logs
- Saving the response to a file or to the job history, storing it in a Job Variable, extracting values from it into Job Variables using JSONPath or XPath, creating Job Variables from a JSON or XML response automatically, and processing it with a script
- Automatic retries for temporary failures
- Importing a request from a curl command, copying the request as a curl command, and testing the request from the Console
See Web Request Task Properties Window for details.
Examples
Chaining API calls
A job can use one Web Request Task to create a record and a second to retrieve it:
- The first step sends a POST request with a Raw JSON body to https://api.example.com/orders. On the Response page, an extraction rule sets the variable OrderID using the JSONPath expression $.id.
- The second step sends a GET request to https://api.example.com/orders/%OrderID%/status.
Obtaining a token from one request and using it in another
For APIs that issue tokens through a login request that is not standard OAuth 2.0, use one step to send the login request and extract the token into a Job Variable (for example, ApiToken), then use Bearer token authentication with the token %ApiToken% in the following steps.
Related Tasks and Triggers
The Web Request Task is used to request a URL as part of job processing. If you want to trigger a job based on the response (or non-response) of a Web server, use the Computer Monitor Trigger instead.
To download files using FTP or SFTP, or to transfer files to and from cloud storage services, use the File Transfer Task.
Job Variables
The Web Request Task sets the following Job Variables, which can be used by subsequent operations in the job:
| Variable | Description |
| WebRequest.RequestURL | The URL requested by the task, including query parameters. Secret values are masked. |
| WebRequest.StatusCode | The HTTP status code returned by the remote server. |
| WebRequest.ReasonPhrase | The HTTP reason phrase returned by the remote server (for example, "OK" or "Not Found"). |
| WebRequest.ResponseContentType | The media type of the response (for example, "application/json"). |
| WebRequest.AttemptCount | The number of times the request was sent, including retries. |
| WebRequest.ResponseFileName | The name of the file where the server response (file or page) was saved, if the save to file option was selected. |
| WebRequest.ResponseHeader.* | The value of each response header, if the option to store response headers was selected (for example, WebRequest.ResponseHeader.ETag). |
| WebRequest.Response.* | Values from a JSON or XML response, if the option to create variables from the response was selected. The variable name is the configured prefix (WebRequest.Response. by default) followed by the path of the value (for example, WebRequest.Response.data.items[0].id). |
The task can also set Job Variables that you specify, from the response body, from response headers, and from values extracted from the response. See Web Request Task Properties Window.