Rest Client

Sends HTTP requests to a provided web server and receives responses from it. Supports URI-encoded and JSON-formatted requests. With this operator, it is possible to build integration with 3d part systems like marketing tools (HubSpot, Active Campaign, SalesManago), validation services (VAT Validators, e-mail verification services), or with your custom-developed systems if they have REST API.

inputs:

url – input the link to the REST API, a specific method to call, or a URI-encoded call. To compose URL it is possible to use either Concatenate Strings and combine URL from several Strings or Get Http Query String From Array

example of composing URL request to ActiveCampaign API to get specific Tags using string concatenation

  • Required: yes

http method – select from the list HTTP method of the request: GET, POST, PUT, DELETE

  • Required: yes

headers – input link from Get Http Headers From Structure to provide Headers of the request. Headers are formed as ‘Header Name’ = ‘Header Value’. Headers are composed using Structure operators: in Structure Schema define Headers Names and with Set Structure Fields define Header Values. Finally with Get Http Headers From Structure convert Structure into Headers and input into REST Client operator.

example of composing header to request ActiveCampaign API 

  • Required: no (depends on web server to which request is sent, but doesn’t require by the operator itself)

query parameters – input request body or payload. Query parameters may be composed with:

  1. structure following with Get Rest Parameters From Structure
  2. array using operators from Array group
  3. strings following with Get Rest Parameters from String

example of composing query parameters with array operators:

  • Required: no (depends on web server to which request is sent and request)

Note: POST request requires a body. If there is no body expected for POST request use an empty JSON like this: {​​​​​}​​​​​​​​​​​​

authentication – input authentication data for the request when it is not provided directly in URL or Headers. Authentication may be defined in one of the following ways depending on particular REST API requirements:

  1. Basic Http Authentication – the simplest one, when login and password are transmitted in the ‘Authorization’  header in unencrypted form. For this type of authentication, it is needed to input the output from Basic Http Authentication with defined login and password
  2. Oath2 – input the output from OAuth2 Authentication operator filled with OAuth2 parameters.
  3. If you already have an access token, you can use it in the Get Oauth2 Authentication From Token operator and input its output to authentication input.
  • Required: no  (depends on web server to which request is sent and request, but doesn’t require by the operator itself)

proxy – input proxy settings if they are required to request REST API. Proxy can be defined in two ways:

  1. Use Proxy Settings defined in Sugar settings (Administration->System Settings->Proxy Settings). In this case, input the output from operator Sugar Proxy
  2. Use own proxy settings with operator Proxy
  • Required: no

outputs:

response – the result of the request to REST API. Please note that only JSON format can be processed. It is possible to process the response with:

  1. Structure with Get Structure From JSON, providing input schema with needed parameters from the response
  2. Collection with Get Collection From JSON
    below is an example of parsing response from HubSpot API of GET /contacts/v1/lists/all/contacts/recent using structures and collections
  3. Array with Get Array from Json following with Array operators
    below is the same parsing of response as on the screenshot above but using Array operators

response code – code that was returned as a result. A successful response is 200. Can be used to handle errors:

The request to Sugar REST API can be configured like this:

Click to rate this post!
[Total: 0 Average: 0]

Leave a Reply

Your email address will not be published. Required fields are marked *