Send request Version 16 (Java)
Action group: Integrations
Description
Sends an HTTP request to invoke a RESTful web service.
Action icon
Settings of parameters
Property | Description | Type | Filling example | Mandatory field |
Parameters | ||||
REST service URL | REST service URL. | Robin.String | Yes | |
Method | Request type. Default value is GET. | Robin.String | No | |
Request body | Request body, specified as a JSON string. | Robin.String | No | |
Request parameters | Query string parameters specified in the URL. | Robin.Dictionary | No | |
Form parameters | HTML form parameters for the POST method. | Robin.Dictionary | No | |
Authentication type | The type of authentication that will be used in the request being sent. If you do not fill in the "Authentication parameters" field, the selected "Authentication type" will be ignored. The default value is "No". | Robin.String | No | |
Authentication parameters | Authentication parameters for the request. If "Basic" or "NTLM" authentication type is selected, the dictionary must have "user" and "pass" keys containing the value of login and password, respectively. If the "Bearer Token" type is selected, the dictionary must have the "token" key with the value of the authentication token. | Robin.Dictionary | No | |
Request headers | Set of request headings and their values. Each key in the dictionary is a separate header. | Robin.Dictionary | No | |
Selecting a proxy server | Specifies the settings of the proxy server to be used. You can use the system proxy settings specified at the OS level, or configure custom proxy settings, or connect without a proxy server. By default, the system settings are used. | Robin.String | No | |
Proxy server protocol | Proxy server protocol. For example: http, https. | Robin.String | No | |
Proxy server address | Host name or IP address of the proxy server. | Robin.String | No | |
Proxy server port | Proxy server port. | Robin.String | No | |
Proxy server login | User login to connect to the proxy server. | Robin.String | No | |
Proxy server password | User password to connect to the proxy server. | Robin.Object | true | No |
Get file | Possibility to get files from the request. If "true" is selected, the "Folder path" and "File name" fields must be filled in. | Robin.Boolean | C:\doc\img | No |
Folder path | Path to the folder where you want to save the file received during the request. | Robin.FolderPath | No | |
File name | Name, which will be used to name the file received when the request is executed. The name should be specified along with the extension that the file should have. | Robin.String | true | No |
Overwrite | If the value is "true" and a file with the same name and extension exists in the specified folder, the new file will overwrite it. If "false", the file will not be overwritten and the action will return an error. | Robin.Boolean | true | No |
Disable SSL | If the value is "true", the SSL certificate validation feature will be disabled. | Robin.Boolean | ||
Results | ||||
Response status | The status code of the response received from the web service. Returned when any method is used. | Robin.String | ||
Response headers | Set of headers and their values received from the web service. Returned when any method is used. If there are repeated headers in the response, there will be only one key with that header; the value of the key will be a collection containing all the values of those headers. | Robin.Dictionary | ||
Response body | The body of the response received from the web service, in raw format. Returned when any method is used. | Robin.String | ||
ID | Identifier value from the "Id" header received from the web service. Returned only when using the "POST" method. | Robin.String | ||
Location | Value from the "Location" header received from the web service. Makes sense for statuses 201, 3xx 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.