HTTP Request
Use the HTTP Request activity to make HTTP requests to a target. You can select what HTTP method to use, define your own headers, provide a payload to send, and so on. After the activity completes, it will provide information about the request, such as the HTTP status code and the response received.
Best Practices
Check the Continue on HTTP Error Status Code check box and use a Condition Block to check the HTTP status code of the previous activity. This requires an understanding of the expected response of the API call you are making. For example, you may want to have one condition block check that the status code is 200 (indicating a success) and have another condition block to check that the status code is not equal to 200 (meaning something may have gone wrong).
- There are other 2xx status codes that indicate success, so this logic will vary depending on the API.
- If you are sending a JSON payload in a POST or PUT, we recommend that you build the JSON payload in Python as opposed to directly in the Request Body activity input. Building a JSON in the activity input does not handle escaping, so nested quotes or other complex data can break the JSON syntax.
-
For additional information on using API credentials, see the HTTP Authentication Help topic.
Usage
Complete the following properties to use this activity:
- HTTP Request - Specify the following information or click the Variable Reference icon to choose a variable:
- Relative URL - Enter the relative URL for the requested resource using an explicit path (example: /url/xyz.html) instead of one with variables (not: [$workflow..local.Request Path$]). Using variables for request parameters is OK.
- Method - Click the drop-down menu and choose the API method to interact with the HTTP endpoint.
- Request Body - Enter the body of the request in JSON format.
- Headers - Specify the following information or click the Variable Reference icon to choose a variable:
Content Type - Click the drop-down menu and choose the content type.
Accept - Enter the MIME type for the Accept header.
User-Agent - Enter any applicable information for the User-Agent header.
Custom Headers - To include custom headers, click Add and enter the Header and Value.
For information about authentication headers, see the HTTP Authentication Help topic.
Cookie - Click Add and enter any applicable information for the cookie header.
Allow Auto Redirect - Check the check box to allow auto-redirects.
- Behavior
-
Allow Sensitive Headers Redirect - Check the check box to allow redirects for sensitive headers such as “Authorization”, “WWW-Authenticate”, “Cookie”, or “Cookie2”. This property allows Automation to pass the authorization along with the redirect.
-
- Continue on HTTP Error Status Code - Check this check box to allow the header request to continue when the request receives an HTTP error status code.
Sample Workflows
The following sample workflows are available in our repository’s workflows folder to help you get familiar with this concept. These can be imported using the instructions in Import Git Content or you can click the workflow to view it in GitHub.