Skip to main content

REST API

Overview

A REST API is an application programming interface that conforms to the constraints of REST (representational state transfer) architectural style and allows for interaction with RESTful web services.

REST APIs work by fielding requests for a resource and returning all relevant information about the resource, translated into a format that clients can easily interpret (this format is determined by the API receiving requests). Clients can also modify items on the server and even add new items to the server through a REST API.

Cinchy v5.5 added support for the URL_ESCAPE and JSON_ESCAPE functions to be used in REST API data syncs anywhere a "parameter" could be utilized (Ex: Endpoint URL, Post Sync Script, etc.). These functions escape parameter values to be safe inside of a URL or JSON document respectively.

info

Before you set up your data sync destination, make sure to configure your Source.

tip

The REST API destination supports batch and real-time syncs.

Destination tab

The following table outlines the mandatory and optional parameters you will find on the Destination tab (Image 1).

The following parameters will help to define your data sync destination and how it functions.

ParameterDescriptionExample
DestinationMandatory. Select your destination from the drop-down menu.REST API

Next steps

Appendix A - API Specifications

Retry configuration

Retry Configuration automatically retries HTTP Requests on failure based on a defined set of conditions. A single retry configuration is defined for the REST API target, and applies to all requests configured in the Insert, Update, and Delete specifications. This capability provides a mechanism to recover from transient errors such as network disruptions or temporary service outages.

caution

Note: the maximum number of retries is capped at 10.

To set up a retry configuration:

  1. Under the REST API destination tab, select API Specification > Retry Configuration

  2. Select your Delay Strategy.

  • Linear Backoff: Defines a delay of approximately n seconds where n = current retry attempt.
  • Exponential Backoff: A strategy where every new retry attempt is delayed exponentially by 2^n seconds, where n = current retry attempt.
    • Example: you defined Max Attempts = 3. Your first retry is going to be in 2^1 = 2, second: 2^2 = 4, third: 2^3 = 8 sec.
  1. Input your Max Attempts. The maximum number of retries allowed is 10.

  2. Define your Retry Conditions. You must define the conditions under which a retry should be attempted. For the Retry to trigger, at least one of the "Retry Conditions" has to evaluate to true.

info

Retry conditions are only evaluated if the response code isn't 2xx Success.

Each Retry Condition contains one or more "Attribute Match" sections. This defines a Regex to evaluate against a section of the HTTP response. The following are the three areas of the HTTP response that can be inspected:

  • Response Code
  • Header
  • Body

If there are multiple "Attribute Match" blocks within a Retry Condition, all have to match for the retry condition to evaluate to true.

caution

The Regex value should be entered as a regular expression. The Regex engine is .NET and expressions can be tested by using this online tool. In the below example, the Regex is designed to match any HTTP 5xx Server Error Codes, using a Regex value of 5[0-9][0-].
For Headers, the format of the Header string which the Regex is applied against is {Header Name}={Header Value}. For example Content-Type=application/json.

Request specifications

Insert specification

Select either:

  • Conditional Flow
  • Request
    • HTTP Method: GET, POST, PUT, PATCH, DELETE
    • Endpoint URL: Refers to where this request will be made to and inserted.

Update specification

Select either:

  • Conditional Flow
  • Request
    • HTTP Method: GET, POST, PUT, PATCH, DELETE
    • Endpoint URL: Refers to where this request will be made to and updated.

Delete specification

Select either:

  • Conditional Flow
  • Request
    • HTTP Method: GET, POST, PUT, PATCH, DELETE
    • Endpoint URL: Refers to where this request will be made to and deleted.

Request subsections

Request Headers

For more information, see the page about request headers.

Files

Use this to upload a file to the target API.

Body

Use this section to add body content.

Variables to Extract

You can choose to specify variables to extract from your REST response.

ParameterDescriptionExample
NameThe name of the variable you wish to extract.Value
Extract vale fromThe response area you want to extract fromResponse Body, Response Header
Path in ResponseThe path to the above variable.$.headers.variable
Header Vale RegexExpression using .NET regex to capture a single value. See .NET Regular Expressions for more info.([^\/]+$)

For more information, please see the Variables page.