How to Build a POST Request for a REST Endpoint with Replacement Variables

Document created by dprostko on Apr 1, 2015Last modified by Adam Arrowsmith on Sep 25, 2017
Version 4Show Document
  • View in full screen mode

This article describes how to send data via HTTP POST along with dynamic "Replacement Variable" values configured in the operation.

 

 Get the example process used below from the Process Library here.

 

 

Use Case

You need to build a POST request for a generic RESTful web application using an HTTP Client connector, however you also need to set dynamic values for replacement variables defined within the HTTP Client Operation. The replacement variables could be defined for HTTP Headers or portions of the Resource Path.

 

For example, you need to POST a document payload to a REST endpoint but also pass dynamic values for the query parameters like this:

 

https://www.mycoolapp.com/crm/customer?subsidiary=AMER&region=US-EAST

 

Approach

Use a Set Properties shape before the Connector shape to set dynamic document properties whose names match the replacement variables defined in the HTTP Operation component. The dynamic document property name must match the name exactly (e.g. case sensitive) of the replacement variable.

 

IMPORTANT: Do NOT use the Parameters tab on the Connector shape to set the replacement variable values. This will disregard the document data payload passed to the Connector shape and effectively send a blank payload to the endpoint.

 

Implementation

  1. Create and configure an HTTP Client Connection for the base URL: https://www.mycoolapp.com/crm 
  2. Create and configure an HTTP Client Operation with a mix of static and replacement variable elements to build out the remainder of the URL Resource Path. Note the two replacement variables, HTTP_SUBSIDIARY and HTTP_REGION.
    •  Variable names are arbitrary but consider adopting a naming convention such as all-caps with "HTTP" prefix to distinguish from other dynamic document properties you might be using.
  3. Use a Set Properties shape before the Connector to set values for the two replacement variables using dynamic document properties. The property names must match the replacement variable name exactly. 
    •  Do not set the replacement variables using the Parameters tab on the Connector shape.

 

When the process executes, the final endpoint will assembled from the base URL defined in the Connection component and the Resource Path elements including the dynamic replacement variables defined in the Operation component. The document data passed to the Connector shape will be POSTed as the request payload.

18 people found this helpful

Attachments

    Outcomes