REST API
Last updated
Last updated
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.
Before you set up your data sync destination, make sure to configure your Source.
The REST API destination supports batch and real-time syncs.
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.
Destination
Mandatory. Select your destination from the drop down menu.
REST API
Define your Sync Actions.
Add in your Post Sync Scripts, if required.
Define your Permissions.
If you are running a real-time sync, set up your Listener Config and enable it to begin your sync.
If you are running a batch sync, click Jobs > Start a Job to begin your sync.
Cinchy v5.5 introduced the Retry Configuration for REST API targets. This will automatically retry 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.
Note: the maximum number of retries is capped at 10.
To set up a retry configuration:
Under the REST API destination tab, select API Specification > Retry Configuration
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.
Input your Max Attempts. The maximum number of retries allowed is 10.
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.
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.
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
.
This section has the same parameters as the usual REST API Source. For more information, seethe Rest API source page
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.
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.
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.