REST Post [Not Recommended]

REST Post [Not Recommended]

Overview

You can use the REST Post Snap to to execute the HTTP Post method on a REST API service endpoint to create business object resources. The Snap also assigns a new URI to every business object that it creates. and returns this URI in the output view.

Prerequisites

None.

Supported Features

Works in Ultra Pipelines. We recommend you to set the batch size to 1.

Limitations and Known Issues

None.

Snap Views

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input 

Document

  • Min: 0

  • Max: 1

  • Mapper

  • Script

  • Router

Each input document offers details associated with the data that must be posted to the target RESTful server.

Output

Document

  • Min: 0

  • Max: 1

  • JSON Splitter

  • JSON Formatter

  • Join

Each output document contains details associated with the outcome of the Post request.

 

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 while running the Pipeline by choosing one of the following options from the When errors occur list under the Views tab:

  • 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*


DefaultValueREST Post
ExampleUpload New Files

String

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 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 hostname 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:

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

Batch size


DefaultValue: N/A
Example: 20

String

Show all headers


Default Value: Deselected
Example: N/A

Checkbox

Single file upload: File

 

DefaultValue: N/A
Example: persons.csv

String/Expression

Single file upload: File key

 

DefaultValue:file
Exampleseed

String/Expression

Single file upload: Filename to be used


DefaultValue: N/A
ExampleNewFile.csv

String/Expression

Upload transfer request type

 

DefaultValueChunked transfer encoding
ExampleCalculate content length

Dropdown list

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

  • Chunked transfer encoding

  • Calculate content length

If Chunked transfer encoding is selected, the header "Transfer-Encoding:chunked" will be added to the POST request, and the Snap uploads the given file in chunked transfer encoding.

If Calculate content length is selected, the file size will be calculated and passed with header "Content-Length" in the POST request.

Chunked transfer encoding can be used if the size of the given file cannot be calculated.

Upload body type

 

DefaultValueMultipart from-data
ExampleMultipart related

Dropdown list

Select the content-type processing for the entity body from the options available:

  • Multipart form-data: Sends the configured value of the HTTP entity as a multipart file, with the configured upload file (if not set as blank) sent as a bytes sub-part.

  • Multipart related: Enables you to post files to the Google Drive API and retain the original names.

  • Binary: Sends either the configured value of the HTTP entity or upload file as a binary entity (as bytes with no multipart information). 

 

Single file Upload: Multipart Content-Type

 

DefaultValueapplication/octet-stream
Exampletext/csv

String/Suggestion

Form Upload

Multipart Type

 

Default ValueFILE
Example: TEXT

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

DefaultValuefile
Examplefile, initial_comments, channels

String/Expression

Specify the key required for the multi-part to upload a file or text as required.

HTTP POST uses multi-part entity to achieve the form upload. The form data of its multi-part entity contains key-value pairs. 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.

HTTP Entity

 

DefaultValue: N/A
Example$.entity

String/Expression

Specify the HTTP entity of the file that you want to upload.

 

Filename to be used

 

DefaultValue: N/A
ExampleNewFile.csv

String/Expression

 

Multipart Content-Type

 

DefaultValue: N/A
Exampletext/csv

String/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

 

DefaultValue: Deselected

N/A

Follow redirects

 

DefaultValue: Selected

N/A

Query parameters

Query parameter

 

DefaultValue: N/A
Example: oauth2_access_token

N/A

Specify the name (or key) of the query parameter.

 

Query parameter value

 

DefaultValue: N/A
Example$account.access_token

N/A

Specify the value associated with the query parameter.

 

HTTP Header

Configuring HTTP headers helps avoid problems in reading or opening files uploaded using the REST Post Snap. Refer to the Troubleshooting section, below, for more information.

Key

 

Default Value: N/A
ExampleContent-Type

String/Expression

Specify the name of the HTTP header.

 

Value

 

DefaultValue: N/A
Exampleapplication/json

String/Expression

Specify the value of the HTTP header.

 

Response entity type

 

DefaultValueDEFAULT
Example: TEXT

Dropdown list

Select one of the following response entity types you want the Snap to display in the output document.:

  • DEFAULT - Select this option to enable the Snap to process the response automatically. The response entity is processed automatically based on the Content-Type header in the response. If the content provided does not parse with the provided Content-Type, the snap will result in an error.
    The following two scenarios describe the Snap’s behavior when using the Process Array checkbox::

    • When you select the Process Array checkbox, the Snap parses JSON or XML and produces a stream of documents at the output view.

    • When you deselect the Process Array checkbox, the Snaps sends the data as it is at the output view.   

  • TEXT - Select this option to enable, the Snap to produce an entity of string type.

  • BINARY - Select this option to enable the Snap to produce an entity of byte array type.

Cookie Policy

 

Default Value:Ignore Cookies



ExampleRFC 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

 

DefaultValue900
Example1000

Integer

Connection timeout

 

DefaultValue30
Example45

Integer

Maximum request attempts


DefaultValue5
Example3

Integer

Retry request interval


DefaultValue3
Example10

Integer

Select one of the following response entity types you want the Snap to display in the output document.:

  • DEFAULT - Select this option to enable the Snap to process the response automatically. The response entity is processed automatically based on the Content-Type header in the response. If the content provided does not parse with the provided Content-Type, the snap will result in an error.
    The following two scenarios describe the Snap’s behavior when using the Process Array checkbox::

    • When you select the Process Array checkbox, the Snap parses JSON or XML and produces a stream of documents at the output view.

    • When you deselect the Process Array checkbox, the Snaps sends the data as it is at the output view.   

  • TEXT - Select this option to enable, the Snap to produce an entity of string type.

  • BINARY - Select this option to enable the Snap to produce an entity of byte array type.

Retry Policy


DefaultValueConnection errors
ExampleAll errors

Dropdown list

Normalize URL

Checkbox