API

Studio Pro activities > Programming > API. Includes "HTTP request" and "Get OAuth token".

Activities

HTTP requestGet OAuth token
Sends an HTTP request with the specified parametersPerforms an OAuth 2.0 authorization

HTTP request

Description

Sends an HTTP request with the specified parameters. The 'Save value to variable' block appears automatically when choosing the 'HTTP request' activity. It automatically saves the value to a variable. However, the block is not mandatory to use and can be removed from the workflow.

Below is an example of configuring and using the action to get a list of current astronauts in orbit.

GET request: How many people are in space now
http://api.open-notify.org/astros.json

This API returns the current number of people in space. When known it also returns the names and spacecraft those people are on. This API takes no inputs.

📘

Tip

The default content-type used in the HTTP request activity is application/json. Always verify which content-type is accepted by the endpoint you’re trying to use. If the endpoint requires a different content-type, make sure to specify it in the additional headers accordingly.

Request

Response

200: OK
 
{

 "message": "success",

 "number": NUMBER_OF_PEOPLE_IN_SPACE,

 "people": [

 {"name": NAME, "craft": SPACECRAFT_NAME},

 ...

 ]

}

Parameters

URL

Path to the web resource to which a request will be sent, for example, http://en.wikipedia.org/w/api.php.

Method

Enables you to choose a request method: "GET", "POST", "PUT", "DELETE" .

Authorization header

Enables you to add authorization data when needed.

Bearer token

  1. Set a value: allows you to manually specify the authentication token.
  2. Calculate a value: allows you to use a special formula or a special method to define an authentication token.
  3. Save the previous step result: takes the result of the previous workflow activity as the authentication token.

Additional headers

Enables you to set custom http-request headers, for example: {"Content-Type": "application/x-www-form-urlencoded"}.

Query parameters

Enables you to set query parameters as an object.

  1. Save the previous step result: chooses the previous activity result as an object with parameters.
  2. Calculate a value: enables you to use available properties and methods to form an object, for example, {action: "opensearch", search: "JavaScript", format: "xml"}.

Body parameters

Available only if either "POST", "PUT" or "DELETE" method is selected. Contains body parameters as an object.

  1. Save the previous step result: chooses the previous activity result as an object with parameters.
  2. Calculate a value: enables you to use available properties and methods to form an object, for example: {a:1,b:"row"}.

Send file

Available only when the "POST" method is selected. This parameter allows you to send a file in the request.

  1. Set a value: enables you to directly write a path to the file that is to be sent. Clicking the 'Pick' button allows you to manually choose the path.
  2. Save the previous step result: chooses the previous activity result as a path.
  3. Calculate a value: enables you to use available properties and methods to form a path.

Form field file

This parameter contains the key field name in the request body which contains the file path that is to be sent.

  1. Set a value: enables you to directly write the field name, for example, file.
  2. Save the previous step result: chooses the previous activity result as a name.
  3. Calculate a value: enables you to use available properties and methods to form a name.

Certificates

This parameters allows you to attach a client certificate to the request if it is required by the service. To do it, enable the "Attach a client certificate" checkbox and select a certificate from the drop-down list. If you do not have any certificates added, click on the "Add new certificate" button. This will open a popup window with a form to add a certificate. Once the form is filled, press "Add", and the window will be closed. You will be able to find the added certificate on the "Certificates" tab in the settings of Studio Pro. The same setting can be found in Bot Runner.

Comment

Contains an annotation to the activity. The input text will be displayed above the activity name.

Result

The response result is stored in the http_response variable by default. The variable format depends on the address used in the request. For example, if using the Wikipedia API and sending a request with the 'GET' method and {action: "opensearch", search: "JavaScript"} parameters, the following result is returned:

The response from the Wikipedia API:

[

 "JavaScript",

 [

 "JavaScript",

 "JavaScript syntax",

 "JavaScript engine",

 "JavaScript library",

 "JavaScript InfoVis Toolkit",

 "JavaScript Style Sheets",

 "JavaScript templating",

 "JavaScriptMVC",

 "JavaScript framework",

 "JavaScript OSA"

 ],

 [

 "JavaScript (), often abbreviated as JS, is a high-level, interpreted scripting language that conforms to the ECMAScript specification.",

 "The syntax of JavaScript is the set of rules that define a correctly structured JavaScript program.",

 "A JavaScript engine is a computer program that executes JavaScript (JS) code. The first JavaScript engines were mere interpreters, but all relevant modern engines utilize just-in-time compilation for improved performance.JavaScript engines are typically developed by web browser vendors, and every major browser has one.",

 "A JavaScript library is a library of pre-written JavaScript which allows for easier development of JavaScript-based applications, especially for AJAX and other web-centric technologies.",

 "The JavaScript InfoVis Toolkit provides tools for creating Interactive Data Visualizations for the Web.",

 "JavaScript Style Sheets (JSSS) was a stylesheet language technology proposed by Netscape Communications Corporation in 1996 to provide facilities for defining the presentation of webpages.",

 "JavaScript templating refers to the client side data binding method implemented with the JavaScript language.",

 "JavaScriptMVC is an open-source rich Internet application framework based on jQuery and OpenAjax. It extends those libraries with a model–view–controller architecture and tools for testing and deployment.",

 "A JavaScript framework is an application framework written in JavaScript. It differs from a JavaScript library in its control flow: A library offers functions to be called by its parent code, whereas a framework defines the entire application design.",

 "JavaScript OSA, (originally JavaScript for OSA, abbreviated as JSOSA), is a freeware inter-process communication scripting language for the Macintosh computer."

 ],

 [

 "https://en.wikipedia.org/wiki/JavaScript",

 "https://en.wikipedia.org/wiki/JavaScript_syntax",

 "https://en.wikipedia.org/wiki/JavaScript_engine",

 "https://en.wikipedia.org/wiki/JavaScript_library",

 "https://en.wikipedia.org/wiki/JavaScript_InfoVis_Toolkit",

 "https://en.wikipedia.org/wiki/JavaScript_Style_Sheets",

 "https://en.wikipedia.org/wiki/JavaScript_templating",

 "https://en.wikipedia.org/wiki/JavaScriptMVC",

 "https://en.wikipedia.org/wiki/JavaScript_framework",

 "https://en.wikipedia.org/wiki/JavaScript_OSA"

 ]

] 

Usage Examples

This activity allows you to interact with different web-resources so its use range is pretty wide. An example of applying this feature to a robotic process may be a case where you need to connect to a Web-API to get or upload some data.

⬅️

Back to the top


Get OAuth token

Description

This activity performs an OAuth 2.0 authorization. Returns an access token to use in other activities.

Parameters

Authorization URL

  1. Set a value: allows you to manually specify the Authorization URL.
  2. Calculate a value: allows you to use a special formula or a special method to determine the Authorization URL.
  3. Save the previous step result: takes the result of the previous workflow action as the Authorization URL.

Access Token URL

  1. Set a value: allows you to manually specify the Access Token URL.
  2. Calculate a value: allows you to use a special formula or a special method to determine the Access Token URL.
  3. Save the previous step result: takes the result of the previous workflow action as the Access Token URL.

Client ID

  1. Set a value: allows you to manually specify the Client ID.
  2. Calculate a value: allows you to use a special formula or a special method to determine the Client ID.
  3. Save the previous step result: takes the result of the previous workflow action as the Client ID.

Client Secret

  1. Set a value: allows you to manually specify the Client Secret.
  2. Calculate a value: allows you to use a special formula or a special method to determine the Client Secret.
  3. Save the previous step result: takes the result of the previous workflow action as the Client Secret.

Scope

  1. Set a value: allows you to manually specify the Scope.
  2. Calculate a value: allows you to use a special formula or a special method to determine the Scope.
  3. Save the previous step result: takes the result of the previous workflow action as the Scope.

State

  1. Set a value: allows you to manually specify the State.
  2. Calculate a value: allows you to use a special formula or a special method to determine the State.
  3. Save the previous step result: takes the result of the previous workflow action as the State.

Usage

OAuth 2.0 protocol requires human in the loop by design. User has to enter his credentials in the pop-up and allow robot to use the service.

Most of the services has quite long token lifetime: more than 14 days. So it'll be wise decision to keep the token and ask for user's attention only when required.

On screenshot below you can see the example of the workflow that will ask user for authorization only if old token is not valid anymore:

⬅️

Back to the top