HTTP Client
In this article
Overview
The HTTP Client Snap is an advanced REST Snap that enables you to send HTTP requests to a server and receive corresponding HTTP responses. It integrates all commonly used HTTP methods, including DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, and TRACE.
We highly recommend that you use the HTTP Client Snap as a replacement for the REST Snaps.
Snap Type
The HTTP Client Snap is a Transform-type Snap that transforms the data passed through the HTTP request.
Prerequisites
A valid account with the required permissions.
Support for Ultra Pipelines
Works in Ultra Pipelines.
Limitations
The HTTP Client Snap hides the Authorization headers in the debug information for Basic Authentication and Digest Authentication Accounts because of security considerations.
If you specify the Authorization headers manually in the Snap or through the Secured Headers Account, then the headers are displayed in the debug information, but the values are hidden as follows:
Behavior Change
With the 433patches21307
update, pagination evaluation occurs before sending the output to the output view. Therefore, if snap.out.totalCount
is part of the Has next or any other pagination properties, the Snap will not include the count in the output corresponding to the request that produced the output document.
Known Issues
This Snap fails with the
Name may not be null
error when the key-value pair values are empty for the x-www-form-urlencoded Entity Type.The AWS Sig V4 Account does not support Virtual Private Cloud for the HTTP Client Snap.
Snap Views
Type | Format | Number of Views | Examples of Upstream and Downstream Snaps | Description |
---|---|---|---|---|
Input | Binary or Document
|
|
| Each input document includes one of the following:
|
Output | Binary or Document
|
|
| Each output document contains one of the following:
When you include a second output view, the Snap uses this view to output the debug information by capturing the request and response. |
Error | Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the Pipeline by choosing one of the following options from the When errors occur list under the Views tab:
When you select the Enable debug checkbox, the information about the executed request and response is written to the error view in case of errors. Learn more about Error handling in Pipelines. |
Snap Settings
Field Name | Field Type | Field Dependency | Description | ||
---|---|---|---|---|---|
Label*
Default Value: HTTP Client | String | None. | Specify a unique name for the Snap.
| ||
Request Method*
Default Value: GET | String/Expression/Suggestion | None. | Specify a custom method or choose one of the following HTTP request methods:
| ||
URI*
| String/Expression | None. | Specify the service endpoint URL of the REST API. You can provide the URL in one of the following ways:
You can use the canonical name (CNAME) for URI so it's not necessary for the URL to end with The Snap finds the value at the JSON path "$.widget.id" in the input data and replaces "%s" in the URL with the value. You can connect the File Reader and JSON Parser Snaps upstream of the HTTP Client Snap and prepare the following JSON file to the File Reader Snap: [
{ "widget": { "id": "111", "name": "foo" } }
{ "widget": { "id": "555", "name": "bar" } }
]
"https://www.example.com/data/v27.0/sobjects/Account" | ||
Query Parameters | Use this field set to add query parameters to be included in the request. This is optional and can either be defined directly in the URL, as separate parameters or both. | ||||
Parameter Name Default Value: N/A | String/Expression | N/A | Specify the name of the query parameter.
| ||
Parameter Value Default Value:N/A | String/Expression | N/A | Specify the value to assign to the parameter. | ||
HTTP Headers | Use this field set to create the HTTP header key-value pairs required for defining the headers for different types of input (JSON, PDF, DOCX, and so on). If you want to specify only content-type headers, you can configure the Multipart Content-Type property instead. | ||||
Header Name
| String/Expression/Suggestion | N/A | Specify the name of the HTTP header. Alternatively, select one of the following options from the suggestion list:
| ||
Header Value Default Value: N/A | String/Expression | N/A | Specify the value for the HTTP header. | ||
Enable debug
| Checkbox | N/A | Select this checkbox to include the information about the executed request and response in the output document (under the
| ||
Use form encoding for spaces
Default Value: Deselected | Checkbox | N/A | Select this checkbox to enable the Snap to encode any space characters in query parameters using the plus sign (+) instead of the percent-encoding (%20). On selecting this checkbox, the Snap preserves whatever encoding has already been made. So, if you place a plus symbol in the query portion URL or percent-encodes ( Learn more about encoding of query parameters. | ||
Prevent URL encoding
Default Value: Deselected | Checkbox | N/A | Select this checkbox to prevent the Snap from automatic URL encoding of the input URI. Enable this setting to use an already encoded URI. When you deselect this checkbox, the following are some of the characters that are automatically encoded by the Snap: | ||
HTTP Entity | An HTTP entity is the message body you can send in a request or receive from a response. An entity represents both binary and character content. The POST and PUT methods use entities. | ||||
Entity Type
| Dropdown list | N/A | Choose one of the following entity types to include in the request body.
| ||
Multipart Subtype
| String/Expression | Appears on selecting multipart for Entity Type. | Specify the MIME subtype for multipart, which specifies the nature of the message parts and their interrelationship. | ||
Multipart Form | Appears on selecting multipart for Entity Type. Use this field set to configure the fields required to upload multiple files and text. Learn more about Multipart Upload. By default, the Snap Settings display the fields required to upload a file. The data that is sent to the server using this entity type uses the following encoding pattern:
| ||||
Type
| Dropdown list | Appears on selecting multipart for Entity Type. | Choose either of the following multipart types to initiate the upload:
| ||
Key
| String/Expression | Appears on selecting multipart for Entity Type. | Specify the key for the multipart form-data needed to upload a file. The HTTP Client uses multipart entity to achieve the file upload. The form-data of its multipart entity contains key-value pairs. Upload and multipart file key depend on the service endpoint. | ||
Value Default Value: N/A
| String/Expression | Appears on selecting multipart for Entity Type. | Specify the file or text to be uploaded. If Multipart Type is FILE, the following are applicable:
If Multipart Type is a TEXT, then:
| ||
Content Type
| String/Expression/Suggestion | Appears on selecting multipart for Entity Type. | Select the content type headers for the data in the body of the multipart HTTP request. The available options are:
| ||
Form | Use this field set to define key-value pairs for the URL-encoded form entity type. | ||||
Key Default Value: N/A | String/Expression | Appears on selecting x-www-form-urlencoded for Entity Type. | Specify the key of the form entry. | ||
Value Default Value: N/A | String/Expression | Appears on selecting x-www-form-urlencoded for Entity Type. | Specify the value for the key defined above. | ||
Raw Entity Default Value: $ | String/Expression | Appears on selecting raw for Entity Type. | Specify the body to send in the request. If the raw entity is from an input document, the document is converted into JSON. | ||
File Default Value: N/A | String/Expression | Appears on selecting binary for Entity Type. | Specify or upload the file to send in the Post payload. | ||
Pagination | Properties to define pagination settings. Learn more about Pagination. | ||||
Has Next
Default Value: N/A | String/Expression | N/A | Specify the boolean expression to indicate whether there is a next page. Learn more about Has Next in action, Retrieving Contact Information from HubSpot Using Upstream Values . | ||
Total Pages to Fetch Default Value: N/A | Integer/Expression | N/A | Specify the maximum number of pages to fetch. The Snap stops fetching the next page if either the maximum number of pages is reached or the Has Next condition evaluates to | ||
Override URI
| Checkbox | N/A | Select this checkbox to enable the URI to be overridden with the specified Next URI for each pagination request. | ||
Reuse request parameters
| Checkbox | N/A | Select this checkbox to enable the Snap to reuse the specified URI parameters in the pagination requests. You can use the Override Parameters table to overrirde some of them. | ||
Override Headers | Define the headers to be overidden or added in the next pagination request. Headers with the same name are overwritten and new headers are appended. If the value is empty, the header is removed. The header value is evaluated against the response document. | ||||
Name | String/Expression/Suggestion | N/A | Specify the name of the header to be updated or added. | ||
Value | String/Expression | N/A | Specify the value of the header to be udpated or added. | ||
Pagination Interval (seconds)
| Integer | N/A | Specify the interval in seconds between the requests for each page. | ||
Client Settings | Additional settings for the HTTP Client. | ||||
Connection | Properties related to the connection to be established. | ||||
Cookie Policy
| Dropdown list | N/A | Select a Cookie Policy from the following options:
| ||
Trust all certificates
| Checkbox | N/A | Select this checkbox to trust all certificates, such as self-signed certificates.
| ||
Read Timeout (seconds)
| Integer | N/A | Specify the number of seconds the Snap must wait before terminating the request because of a failure to read from the target service. | ||
Connection Timeout (seconds)
| Integer | N/A | Specify the number of seconds for which the Snap must wait before aborting the request due to a failure to establish a connection to the target endpoint or service.
| ||
Retry | Properties for handling retries. | ||||
Retry Condition
| Dropdown list | N/A | Select one of the following options to handle connection and error responses:
| ||
Maximum Attempts
| Integer | N/A | Specify the maximum number of attempts the Snap must make to receive a response. If the attempts do not result in a response, the Snap terminates the request.
| ||
Retry Interval (seconds)
| Integer | N/A | Specify the number of seconds the Snap must wait between two successive requests. A retry happens only when the previous attempt resulted in an exception.
| ||
Automatically retry on 429 responses
| Checkbox | N/A | Select this checkbox to automatically retry the | ||
Use Retry-After header for 429
| Checkbox | N/A | Select this checkbox to enable the Snap to follow the | ||
Redirects | Properties for handling redirections. | ||||
Follow redirects
| Checkbox | N/A | Select this checkbox to accept the response and redirect the request. | ||
Follow original HTTP method
| Checkbox | Appears on selecting the Follow redirects checkbox. | Select this checkbox to enable the Snap to use the original HTTP method to do the redirect request. Otherwise, the GET method is used. | ||
Maximum Number of Redirects
| Integer/Expression | N/A | Specify the maximum number of redirects to allow. | ||
Allow relative redirect
| Checkbox | N/A | Select this checkbox to determine whether relative redirects should be allowed. The HTTP specification requires the location value to be an absolute URI. | ||
Allow circular redirect
| Checkbox | N/A | Select this checkbox to allow circular redirects to the same location. | ||
Output | Properties that define the display of the output. | ||||
Response Type | Dropdown list |
| Choose one of the following response types:
| ||
Extract entity as Documents Default Value: Selected | Checkbox | Appears on selecting JSON for Response Type. | Select this checkbox to extract the response entity as an output document as per the specified JSON path. If the extracted value is a list, it is split. | ||
Write unsuccessful response to Error View Default Value: Deselected | Checkbox | N/A | Select this checkbox to treat all unsuccessful responses (308, 4xx, and 5xx) as errors and write them to the error view. | ||
Include current cookies Default Value: Selected | Checkbox | N/A | Select this checkbox to include current cookies in each output document. | ||
Snap Execution Default Value: Execute only | Dropdown list | N/A | Select one of the following three modes in which the Snap executes:
|
Troubleshooting
Error | Reason | Resolution |
---|---|---|
Stack trace error in the Snap:
| The HTTP Client Snap sends | Provide |
Failed to execute the HTTP request. | The Service URL must have a protocol, such as http://, https://. | Check the Snap properties. Specifically, check your entry in the Service URL field. |
<Service_URL>: Name or service not known. This means that the service URL you entered is not accessible. | ||
Failure: Validation errors: property_map.settings.serviceUrl.value: Could not compile expression: <Service_URL> | The Snap settings are not correct. Encountered extraneous input ':' at line 1:5; expecting={<EOF>, '||', '&&', '^', '==', '!=', '>', '<', '>=', '<=', '+', '-', '*', '/', '%', '?', 'instanceof', 'in', 'matches', '[', '(', '.', PropertyRef}. This means that you turned expressions on () when entering the string value into the Service URL field. | Fix the Snap configuration and try executing again. Check the expression syntax. Ensure that your service URL is a proper expression; or turn off the expression control (). Learn more about Using Expressions.
|
The provided URI is invalid. | Illegal character in schema name. | Verify that the URI and parameters that you provide are syntactically correct. |
Status codes | ||
URL Parse Exception - 403 | The Service URL path might be containing any of the following special characters: !, =, %, #, $, ^&()_¢äâêîôûñç¡¿ÉÙËǨ°¸ðø©¢¾A+²½µ®§÷¶þ | To escape the special characters, use the global function encodeURIComponent on any variables that might contain special characters so that they are encoded properly. |
status code = 404 | Phrase = NOT FOUND, refer to the error_entity field in the error view document for more details. This means that your service URL does not point to the correct endpoint. | Check the values of Snap properties. Specifically, check your service URL. |
status code = 404 | Phrase = NOT FOUND, refer to the error_entity field in the error view document for more details. This means that your service URL does not point to the endpoint that it should. | Check the values of Snap properties. Specifically, check your service URL. |
status code = 406 | NOT ACCEPTABLE. This means that the endpoint is not receiving any details from upstream Snaps. | Ensure that you have valid references in the HTTP entity field. |
status code = 409 | CONFLICT, refer to the error_entity field in the error view document for more details. This happens when you already have the resource that you want to create in the target endpoint. | Verify the values in the Snap configuration. |
Too many Requests - 429 | There are too many requests to the endpoint. | Wait for the retry to succeed. The HTTP Client Snap extracts the response header and automatically retries when it encounters status 429. By default, the retry interval (Retry-After) is specified in the HTTP response header. If no value is available for Retry-After, then the Snap’s Retry Interval value is used. |
Examples
Snap Pack History
Related Content
Have feedback? Email documentation@snaplogic.com | Ask a question in the SnapLogic Community
© 2017-2024 SnapLogic, Inc.