REST Put
In this article
Overview
We recommend that you use the HTTP Client Snap instead of Snaps from the REST Snap Pack to connect to REST-based APIs and applications.
You can use the REST Put Snap to replace business object resources. If the business object does not exist, the Snap creates the object.
Prerequisites
A valid account with the required permissions.
Supported Features
Works in Ultra Tasks. We recommend you to set the batch size to 1.
Limitations and Known Issues
None.
Snap Views
Views | View Type | View Format | Examples of Upstream and Downstream Snaps | Description |
---|---|---|---|---|
Input | Document |
|
| Each input document contains details associated with the data that must be replaced or created in the target RESTful server. |
Output | Document |
|
| Each output document contains details related to the business objects impacted as a result of Snap execution. |
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. The available options are:
Learn more about Error handling in Pipelines. |
Snap Settings
Field Name | Field Type | Description | ||||
---|---|---|---|---|---|---|
Label* Default Value: REST Put | String | Specify a name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your Pipeline. | ||||
Service URL* | String/Expression | Specify the service endpoint URL of REST API. You can provide the URL in one of the following ways:
For example:
For example: For Snaps using AWS Signature V4 accounts, you can use the canonical name (CNAME) for the URI so it's not necessary for the URL to end with amazonaws.com or have the region and service provided in it. However, if you are using the CNAME you must provide it in the AWS Region and Service Name fields in the AWS Signature V4 account. The host name in the CNAME must be equal to the bucket name. For example: New URI with CNAME: Here, the bucket name is The Snap finds the value at the JSON path $.widget.id in the input data and replaces "%s" in the Service URL with the value. You can connect File Reader and JSON Parser Snaps upstream of a REST Put Snap and prepare the following JSON file for the File Reader Snap:
The Service URL for a REST snap has to be valid. If the Service URL contains any special characters, such as !, =, %21, $, and
We recommend you to use the former (encodeURIComponent) method to escape the special characters. | ||||
HTTP Entity
| String/Expression | Enter the JSON path to the HTTP entity data in the input Map data, or leave this field empty if there is no entity data to send to the service URL. | ||||
Batch size
| String | Specify the batch size of the request. The incoming documents will be accumulated in a list up to the defined batch size before it is submitted to the endpoint. You must only set this if your REST endpoint expects a list. | ||||
Show all headers
| Checkbox | Select this checkbox to display the response header values as a list of objects in the output document. If any of these objects is a string in format "key1=value1; key2=value2; ...", it is parsed into a map data. The REST endpoint might return HTTP response with multiple headers with same header name. | ||||
Upload transfer request type
| Dropdown list | Choose the type of encoding that you want to use to safely transfer the entity to the user. The available options are:
| ||||
Form Upload | Use this field set to configure the fields required to upload multiple files and text. Learn more about Multipart Upload.
Multiple file upload settings work similarly across the REST Post, Patch, and Put Snaps. To see an example of these settings in action, see Uploading Multiple Documents Using the REST Post Snap | |||||
Multipart Type
| Dropdown list | Choose the type of multipart upload that you want to initiate. The available options are:
| ||||
Multipart Key
| String/Expression | Enter the key for the multi-part form-data needed to upload a file. HTTP POST uses multi-part entity to achieve the file upload. The form-data of its multi-part entity contains key-value pairs. Upload-file key is dependent on the service endpoint. Multipart Key can be anything and it depends on the service endpoint. This property is expression-enabled. For more information on the expression language, see Understanding Expressions in SnapLogic and Using Expressions. For information on Pipeline Parameters, see Pipeline Properties. | ||||
Multipart Value Default Value: N/A
| String/Expression | Specify the the file or text to be uploaded. If Multipart Type is FILE, the following are applicable:
If Multipart Type is a TEXT, then
For Text part upload using Form Upload, the Http Entity and Filename to be used are ignored. | ||||
Filename to be used
| String/Expression | Enter the filename to be used for the new file created by the Snap. | ||||
Multipart Content-Type
| String/Expression/Suggestion | Select the content type headers for the data in the body of the multipart HTTP request. The available options are:
If the Multipart Type is TEXT, it is generally not required to specify any value in this field. When you do not specify any value, the API uses the default value
| ||||
Trust all certificates
| Checkbox | Select this checkbox to trust all certificates, such as self-signed certificates. | ||||
Follow redirects*
| Checkbox | Select this checkbox to follow HTTP redirects. When selected, if a redirect response (e.g. a 301 or 302 response code) is received, another request to the URL specified in the Location header will be automatically made. When not selected, another request will not be made and the 301/302 response will show up in the output view. | ||||
Query parameters | Use this field set to define query parameters. This is optional and can either be defined directly in the service URL, as separate parameters or both. An example for OAuth2 (LinkedIn enabled endpoint). | |||||
Query parameter
| String/Expression | Specify the name for the query parameter. | ||||
Query parameter value
| String | Specify the value that you want to assign to the parameter. | ||||
HTTP header | Use this fieldset to specify the HTTP header key-value pairs. This field set contains the Key and Value fields. | |||||
Key
| String/Expression | Enter the key for HTTP header. | ||||
Value
| String/Expression | Enter the value for the key parameter. | ||||
Response entity type Default value: DEFAULT | Dropdown list | Choose the response entity type in the output document. The available options include:
If TEXT or BINARY is selected, the Snap will not attempt to parse the entity content. If DEFAULT is selected, the Snap produces the expected result in most cases, but when failed to do so, users may set the Response entity type to TEXT or BINARY. | ||||
Cookie Policy
| Dropdown list | Select a Cookie Policy from the following options:
When using a cookie policy, you must select Show All Headers checkbox to view the parsed cookies from the cookie policy specification. | ||||
Read timeout
| Integer | Specify the time in seconds to wait before aborting the request due to a failure to read from the target service. This option lets you specify a timeout value in seconds after which the request gets aborted.
| ||||
Connection timeout
| Integer | Specify the time in seconds to wait before aborting the request due to a failure to establish a connection to the target service. | ||||
Maximum request attempts
| Integer | Specify the maximum number of attempts to be made to receive a response. The request is terminated if the attempts do not result in a response. | ||||
Retry request interval
| Integer | Specify the interval (in seconds) between two successive requests. A retry happens only when the previous attempt failed. | ||||
Retry Policy Default Value:Connection errors | Dropdown list | Choose the retry policy for connection and error responses. The available options are:
| ||||
Normalize URL | Checkbox | Select this checkbox to normalize the Service URL. This enables the Snap to convert double slashes (//) in the URL path to single slash (/). For example, https://example.com/path//to//file is converted to https://example.com/path/to/file. Deselecting this check box reverts the Snap to 4.19 Snaplex behavior, wherein the URL paths were not normalized by default. In the 4.20 Release, due to the HTTP client upgrade the URL paths were normalized by default. Hence, there was a change in behavior in handling the URL paths in 4.20 release when compared to 4.19. This change in behavior should not impact the existing Pipelines, because most of the websites map URL paths with double or single slashes to the same endpoint. For example, https://snaplogic.com/company/diversity and https://snaplogic.com//company//diversity direct to the same endpoint. Therefore, we recommend you to select the Normalize URL checkbox. However, an exception to this is when you use non-standard URLs that differentiate the URL paths containing double slashes from those with single slashes and map them to different endpoints, in which case you must deselect Normalize URL check box. Default Value: Selected | ||||
Snap Execution Default Value: Execute only | Dropdown list | Select one of the three modes in which the Snap executes. Available options are:
|
Troubleshooting
Error | Reason | Resolution |
---|---|---|
Failed to execute HTTP request | The Service URL must have a protocol, such as http://, https://. | Please check the Snap properties. Specifically, check your entry in the Service URL field. |
<Service_URL>: Name or service not known. This basically 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 have turned expressions on () while entering string value into the Service URL field. | Please fix the snap configuration and try the execution again. Please check expression syntax. Specifically, ensure that your service URL is a proper expression; or turn off the expression control (). For more information on the expression language, see Understanding Expressions in SnapLogic and Using Expressions. |
HTTP entity: <string_in_HTTP entity field> is undefined. Perhaps you meant: <List of variables received from the upstream Snap>. | Either there is an error in the value in the HTTP entity field, or you have used string input while having expressions enabled. | Check the spelling of the variable. Also, check whether your HTTP entity entry requires expressions. Update Snap settings as appropriate. |
REST API service endpoint returned error result: status code = 400 | Reason phrase = BAD REQUEST, refer to the error_entity field in the error view document for more details. You typically see this message when:
| Check the values of Snap properties. Specifically:
|
File not found: <File URL> | File not found on <server URL> at <complete address of file to be uploaded> | Address the reported issue. Check the location of the file to be uploaded. |
Single file upload: <Name of field>: <name of file> is undefined. Perhaps you meant: <options based on your input> | null | Check the spelling of the variable. Specifically, check whether the expressions toggle is turned on even though it is not required. |
REST API service endpoint returned error result: 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. | Check the values of Snap properties. |
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. |
Too many Requests - 429 | There are too many requests to REST endpoint. | Wait for the retry to succeed. Rest related Snaps extract the response header and automatically retry when they encounter 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
Adding Members to SnapLogic Groups
In this example, we add members to a SnapLogic group.
We design the Pipeline as shown below:
We configure the JSON Generator Snap to enter details associated with the member that you want to add to the target group.
We configure the REST Put Snap, enter the account details in the Account tab, and configure the Snap to send the REST request to the endpoint.
- We enter the service URL associated with the group in which you want to add the member. For information on creating the service URL, see Update Member List.
- We specify a header to the call, indicating that the "Content-Type" in the body of your REST call is "application/JSON".
We save and execute the Pipeline. Once the Pipeline completes executing, the REST Put Snaps displays details associated with the operation performed.
Downloads
Important steps to successfully reuse Pipelines
- Download and import the pipeline into the SnapLogic application.
- Configure Snap accounts as applicable.
- Provide pipeline parameters as applicable.
Snap Pack History
Have feedback? Email documentation@snaplogic.com | Ask a question in the SnapLogic Community
© 2017-2024 SnapLogic, Inc.