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

ViewsView TypeView FormatExamples of Upstream and Downstream SnapsDescription
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.
OutputDocument
  • 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 NameField 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:

  • Use the global function encodeURIComponent on any variables that might contain special characters so that they are encoded properly. For example, 
    '