REST Put [Not Recommended]

REST Put [Not Recommended]

Overview

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

  • Min: 0

  • Max: 1

  • Mapper

  • Script

  • Router

Each input document contains details associated with the data that must be replaced or created in the target RESTful server.

Output

Document

  • Min: 0

  • Max: 1

  • JSON Splitter

  • JSON Formatter

  • Join

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:

  • Stop Pipeline Execution: Stops the current pipeline execution when the Snap encounters an error.

  • Discard Error Data and Continue: Ignores the error, discards that record, and continues with the remaining records.

  • Route Error Data to Error View: Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap Settings

Field Name

Field Type 

Description

Label*

Default Value: REST Put
Example: 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:

  • As a JavaScript expression in the expression language.

For example: http://coresnapsqa-v4.s3.us-east-2.amazonaws.com/S3Account/'+encodeURIComponent("Special_char_owner_!3)12.json")

  • As a plain string that you should enclose in double quotes ("").

For example: "https://www.example.com/slm/webservice/v2.0/defect/%s".replace("%s", $.widg et.id)

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:
Previous URI: https://jsmith-bucket.nia3.snaplogic.net.s3.us-west-1.amazonaws.com/HttpClientTest/test1

New URI with CNAME: https://jsmith-sltest.nia3.snaplogic.net/HttpClientTest/test1

Here, the bucket name is jsmith-bucket.nia3.snaplogic.net

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 ^, the Snap throws an exception error. You can escape the special characters (using expression language) using one of the following methods:

We recommend you to use the former (encodeURIComponent) method to escape the special characters.

HTTP Entity



Default Value: (the HTTP entity data is at the root of the input Map data)
Example: $.entity (if the HTTP entity data is the value of the "entity" key at the root of the input Map data)

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


Default Value: N/A
Example:2

 

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


Default Value:Deselected

 

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.
If you do not select this checkbox,  only one response header is shown in the output document. 

 

Upload transfer request type


Default Value:Chunked transfer encoding
Example:Calculate content length

Dropdown list

Choose the type of encoding that you want to use to safely transfer the entity to the user. The available options are:

  • Chunked transfer encoding: On selecting this option, the Snap adds the header "Transfer-Encoding:chunked" to the PUT request, and uploads the given file in chunked transfer encoding format.

  • Calculate content length: On selecting this option, the file size is calculated and passed with header "Content-Length" in the PUT request. You can use Chunked transfer encoding if the size of the given file cannot be calculated.

 

Form Upload

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. Click the Add

 icon to add new rows for adding file or text. This field set contains the following fields:

  • Multipart Type

  • Multipart Key

  • Multipart Value

  • HTTP Entity

  • Filename to be used

  • Multipart Content-Type

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


Default ValueFILE
ExampleTEXT

Dropdown list

Choose the type of multipart upload that you want to initiate. The available options are:

  • FILE: Use this option to upload a file.

  • TEXT: Use this option to upload text.

 

Multipart Key


Default Value: N/A
Examplefile

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.

Multipart Value

 

Default Value: N/A
Example

String/Expression

Specify the the file or text to be uploaded.

If Multipart Type is FILE, the following are applicable:

  • The file protocols supported for file values are 'sldb:///' and 'file:///'.

  • If the file path is a relative path, it is considered as an SLDB file.

  • If this field is not empty, HTTP Entity and Batch size fields are ignored and the Multipart Key field is required.

  • If the value is an expression, the input document is used to evaluate the expression. Each input document invokes one file upload.

  • This field does not support wildcard or glob patterns.

If Multipart Type is a TEXT, then

  • The value should be expression enabled and enclosed in double quotes.

For Text part upload using Form Upload, the Http Entity and Filename to be used are ignored.

Filename to be used


Example: file.csv

String/Expression

Enter the filename to be used for the new file created by the Snap.

Multipart Content-Type


DefaultValue: N/A




Exampletext/csv

String/Expression/Suggestion

Select the content type headers for the data in the body of the multipart HTTP request. The available options are:

  • application/octet-stream

  • text/plain

  • application/json

  • text/csv

  • text/html

  • image/jpeg

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 text/plain; charset=UTF-8.

  • To specify other HTTP headers configure the headers in the HTTP header field set.

  • If you configure both Multipart Content-Type and HTTP header fields, the value in the Multipart Content-type gets precedence. 

Trust all certificates


Default Value:Deselected
Example: N/A

Checkbox

Select this checkbox to trust all certificates, such as self-signed certificates.

 

Follow redirects*


Default value: Selected

 

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


Default Value: N/A




Example: oauth2_access_token

String/Expression

Specify the name for the query parameter.

 

Query parameter value 


Default Value: N/A




Example$account.access_token

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


Default Value: N/A
Example: Content-Type

String/Expression

Enter the key for HTTP header.

 

Value


Default Value: N/A
Example: SnapLogic

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:

  • DEFAULT - If selected, the response entity is processed automatically. The Snaps attempts to convert the entity to a string or a byte array depending on the response headers.

  • TEXT - If selected, the Snap produces an entity of string type.

  • BINARY - If selected, the Snap produces an entity of byte array type.

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


Default Value: Ignore Cookies




Example: RFC Strict

Dropdown list

Select a Cookie Policy from the following options:

  • Browser Compatibility: This policy is compatible with different servers even if they are not completely standards-compliant. If you are facing issues while parsing cookies, you should try using this policy.

  • Ignore Cookies: This cookie policy ignores all cookies. You should use this policy to prevent HTTP Client from accepting and sending cookies.

  • RFC Strict: This policy uses the set-cookie header

  • RFC Lax: The policy uses set-cookie and set-cookie2 for parsing.

When using a cookie policy, you must select Show All Headers checkbox to view the parsed cookies from the cookie policy specification.

Read timeout


Default Value: 900 seconds

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. 

  • In some cases, the request does not return, such as during network issues. For those a timeout can be configured to allow failing fast. 

  • Every Snap instance can have its own timeout settings.

  • The Snap will execute five retries within a couple of seconds back-off time before it fails.

Connection timeout


Default Value: 30
Example: 10

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


Default Value: 5
Example: 3

 

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


Default Value:3
Example:10

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
Example: Connection and server errors

Dropdown list

Choose the retry policy for connection and error responses. The available options are:

  • Connection errors: Occur when a client fails to establish a secure connection to the server.

  • Connection and auth errors (401/403): Occurs when either the user authorization fails or access to the page/resource is forbidden.

  • Connection and client errors (4xx): Occurs when the request for the resource contains bad syntax, or when the resource is not found (404).

  • Connection and server errors (5xx): Occurs when the server is unable to complete a request.

  • All errors: Applies to all of the above-listed errors.

 

Normalize URL

Checkbox

Snap Execution

Default Value: Execute only
Example: Validate & Execute

Dropdown list

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 ().