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

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
Endpoint URLEndpoint URLRobin.String
Yes
MethodThe method of request being created. By default, Get.Robin.String
No
Request bodyThe body of the request to be sent. Allows you to send a request as a JSON stringyRobin.String
No
Query ParametersQuery ParametersRobin.Dictionary
No
Form ParametersForm Parameters of POST methodRobin.Dictionary
No
AuthorizationDictionary 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 HeadersRequest HeadersRobin.Dictionary
No
File path for sending by POST methodThe path to the file to be attached to the requestRobin.FilePath
No
Proxy server settingsSpecifies 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 protocolThe protocol of the proxy server. For example, http, httpsRobin.String
No
The hostname, or address, of the proxy serverThe hostname, or address, of the proxy serverRobin.String
No
The port number of the proxy serverThe port number of the proxy serverRobin.String
No
The username of the proxy serverThe username of the proxy serverRobin.String
No
The password of the proxy serverThe password of the proxy serverRobin.Object
No
Get fileAbility to get files from a request. If «true» is selected, the «Path to folder» and «File name» fields must be filled in.Robin.BooleantrueNo
Path to fileThe path to the folder where the resulting file should be saved.Robin.FolderPathC:\doc\imgNo
File nameA field for the file name with an extension.Robin.String
No
OverwriteOverwrite 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.BooleantrueNo
Disable SSLDisable SSL. If the value is true, then SSL certificate verification will be skipped. The default value is false.Robin.BooleantrueNo
Results
Response statusResponse 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 bodyResponse body. Returned by all methodsRobin.String

IdentificatorA string variable to which the identifier from the "Id" response header will be written. Returned by POST method onlyRobin.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

  1. Move the "Send request" action to the workspace and set its parameters. 
  2. 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/

  3. The "Method" field - in our case it is necessary to specify the GET value. 

  4. "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. 

  5. 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. 

  6. 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. 

  1. 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.
  2. The "Method" field - in our case we need to specify the POST value.
  3. Field "Request body" - it is necessary to specify the text of the request body. {"query": "Skirt shorts"}
  4. 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:
  5. 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.

  6. "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. 

  7. 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. 

  8. The "Overwrite" field is necessary in case this folder already contains a file with the same name and extension.

  9. 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

  1. 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. 
  2. The "Method" field - in our case we need to specify the POST value. 
  3. 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). 
  4. 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. 
  5. 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.  
  6. 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:
  7. Example of filling in the "Request Headers" field:
  8. 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. 
  9. 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. 
  10. 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
  11. In the "Proxy server settings" field you should choose which option to use
  12. 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. 
  13. 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. 
  14. If "System proxy" or " Without proxy" is selected, the fields below can be left blank. 
  15. Only if "Custom proxy" is selected, the fields below must be filled in (highlighted on the screen).  
  16. Other fields are related to receiving a file from the service. 
  17. 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. 
  18. 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. 
  19. The "Overwrite" field is necessary in case this folder already contains a file with the same name and extension
  20. 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.  

  • Нет меток