Send request Version 15 (Java)
Action group: Integrations
Description
The action sends an HTTP request to invoke a RESTful web service
Action icon
Settings of parameters
Property | Description | Type | Filling example | Mandatory field |
Parameters | ||||
Endpoint URL | Endpoint URL | Robin.String | Yes | |
Method | The method of request being created. By default, Get. | Robin.String | No | |
Request body | The body of the request to be sent. Allows you to send a request as a JSON stringy | Robin.String | No | |
Query Parameters | Query Parameters | Robin.Dictionary | No | |
Form Parameters | Form Parameters of POST method | Robin.Dictionary | No | |
Authorization | Dictionary with authorization parameters - Basic or Bearer Token. In the case of Basic authorization, the dictionary must have the keys «user» and «pass», and the values of the dictionary elements must contain the username and password. In case of Bearer Token authorization, the dictionary must have the «token» key, and the element value must contain the Bearer Token. | Robin.Dictionary | No | |
Request Headers | Request Headers | Robin.Dictionary | No | |
File path for sending by POST method | The path to the file to be attached to the request | Robin.FilePath | No | |
Proxy server settings | Specifies the settings for the proxy server to use. You can use the system proxy settings set at the OS level, or configure custom proxy settings, or connect without a proxy server. The system settings are used by default. | Robin.String | No | |
Proxy server protocol | The protocol of the proxy server. For example, http, https | Robin.String | No | |
The hostname, or address, of the proxy server | The hostname, or address, of the proxy server | Robin.String | No | |
The port number of the proxy server | The port number of the proxy server | Robin.String | No | |
The username of the proxy server | The username of the proxy server | Robin.String | No | |
The password of the proxy server | The password of the proxy server | Robin.Object | No | |
Get file | Ability to get files from a request. If «true» is selected, the «Path to folder» and «File name» fields must be filled in. | Robin.Boolean | true | No |
Path to file | The path to the folder where the resulting file should be saved. | Robin.FolderPath | C:\doc\img | No |
File name | A field for the file name with an extension. | Robin.String | No | |
Overwrite | Overwrite existing file. If the value of the parameter is false, and a file with the same name and extension already exists in the specified folder, an error will be raised. The default value is false. | Robin.Boolean | true | No |
Disable SSL | Disable SSL. If the value is true, then SSL certificate verification will be skipped. The default value is false. | Robin.Boolean | true | No |
Results | ||||
Response status | Response status code. Returned by all methods. | Robin.String | ||
Response Headers. | Response Headers. Returned by all methods. If there are repeated headers in the response from the server, their values are collected into a separate collection, which is stored in the dictionary with the header as the key. | Robin.Dictionary | ||
Response body | Response body. Returned by all methods | Robin.String | ||
Identificator | A string variable to which the identifier from the "Id" response header will be written. Returned by POST method only | Robin.String | ||
Указатель ресурса | The Location response header indicates the URL to redirect a page to. It only provides a meaning when served with a 3xx (redirection) or 201 (created) status response and only for POST method. | Robin.String |
Special conditions of use
Read more about REST.
Example of use 1
Task
Send a GET request to https://dadata.ru/api/find-party/ , saving the result of the response to a json file.
Solution
Use the "Send request" action.
Implementation
- Move the "Send request" action to the workspace and set its parameters.
The "Endpoint URL" field is the address to connect to. More detailed information about the method can be found at the following link: https://dadata.ru/api/find-party/.
The "Method" field - in our case it is necessary to specify the GET value.
"Get file" field - it is necessary to check the checkbox if necessary. It is used when it is necessary to receive a file from the service. The whole response from the service will be written to a separate file.
The "Path to file" and "File name" fields - must be filled in if the checkbox in the "Get file" field is checked. In the "File name" field it is necessary to specify the extension.
- Click on the "Start" button in the top panel.
Result
The program robot completed successfully. A .json file with the response from the service was saved.
Example of use 2
Task
Send a POST request to the http://shop.bugred.ru/api/items/search/ service to retrieve actual product data and parse the response from the service, saving the result of the response to a .txt file.
Solution
Use the "Send request" action.
Implementation
Move the "Send request" action to the workspace and set its parameters.
- The "Endpoint URL" field is the address to connect to (REST request) - http://shop.bugred.ru/api/items/search/. More detailed information about the method can be found at the following link.
- The "Method" field - in our case we need to specify the POST value.
- Field "Request body" - it is necessary to specify the text of the request body. {"query": "Skirt shorts"}
- Field "Request Headers" - a dictionary in which you need to specify the name of headers and their keys. In our case, a dictionary of 2 records. Example of filling in the "Request Headers" field:
All other fields are irrelevant to the meaning of the request and its format. The fields starting from " Proxy server settings" and ending with the field "The password to the proxy server" are all fields that are related to proxy server configuration, if it is required. In our case, there is no proxy server.
"Get file" field - it is necessary to check the checkbox if necessary. It is used when it is necessary to receive a file from the service. The whole response from the service will be written to a separate file.
The "Path to file" and "File name" fields - must be filled in if the checkbox in the "Get file" field is checked. In the "File name" field it is necessary to specify the extension.
The "Overwrite" field is necessary in case this folder already contains a file with the same name and extension.
When launching the robot, you need to click on the "Start" button in the top panel.
Result
The robot completed successfully. The response from the service is parsed by the robot.
Example of use 3
Task
It is necessary to send rest-request to the service https://dadata.ru/ to get actual data about the organization and parse the response from the service.
The solution shows how to correctly fill in the parameters for a particular task, as well as other parameters are considered.
Solution
Use the "Send request" action. The entire workflow is shown in the robot's flowchart rest-zapros.robin-source .
Transfer the "Send request" action to the workspace and customize its parameters.
Result
Let's look at the action parameters in detail
- The "Endpoint URL" field is the address to connect to. We will connect to the dadata service. The body of the request looks like one line. The data is formed in JSON format.
- The "Method" field - in our case we need to specify the POST value.
- The "Request body" field - it is necessary to specify the text of the request body. If the parameters should be passed not in the body, but in the URL, then in this case the parameters of the request should be specified in the URL. It depends on the service, i.e. how the service expects to receive the request (in the body of the request or in the URL).
- The "Form Parameters" field - in this field you can fill in the values for the request body. Difference from the "Request body" field: "Request body" is a string, "Form parameters" is a dictionary. The "Form parameters" field is used for POST method. The dictionary contains JSON object names, element names and further values for these elements.
- The "Query parameters" field - is needed in case the service expects that the parameters of the request will be passed through the URL, and not through the body of the request.
- The "Request Headers" field is a dictionary in which you need to specify the name of headers and their keys. In our case, the dictionary consists of 3 entries:
- Example of filling in the "Request Headers" field:
- One of the headers is the header with authorization. It can be specified in the "Authorization" field, but it will not be an error if this header is specified in the "Request Headers" field.
- Field "File path for sending by POST method"- it is necessary to specify the path to the file with the request, if it is required.
- All other fields are irrelevant to the meaning of the request and its format. Fields from "Proxy server settings" to "The password of the proxy server" are all fields that are related to proxy server configuration, if it is required
- In the "Proxy server settings" field you should choose which option to use
- If the system proxy server is selected, the server settings that are set in your system under which the robot is running will be used.
- If "Without proxy" is selected, neither system settings nor any other settings are used. then neither system settings nor any other settings will be used.
- If "System proxy" or " Without proxy" is selected, the fields below can be left blank.
- Only if "Custom proxy" is selected, the fields below must be filled in (highlighted on the screen).
- Other fields are related to receiving a file from the service.
- The"Get file" field - it is necessary to check the checkbox if necessary. It is used when it is necessary to receive a file from the service. The whole response from the service will be written to a separate file.
- The "Path to file" and "File name" fields - must be filled in if the checkbox is checked in the "Get file" field. In the "File name" field it is necessary to specify the extension.
- The "Overwrite" field is necessary in case this folder already contains a file with the same name and extension
- When launching the robot, you need to click on the "Start" button in the top panel.
Result
The robot completed successfully. The response from the service is parsed by the robot.