Rest Wizard
This wizard appears on the screen once the activity is dragged and dropped to the workflow.
URL: Enter the URL or API which needs to be called on to make the request.
Methods: The REST API can issue requests to the URL, of which there are eight types:
1. GET- This requests the webpage to extract the information/ details/ Method from the URL. Click here to know a detailed
explanation.
2. PUT- This request is used to update a method/ service in the URL.
3. POST – This request is used to create a service/ method in the URL. Click here to know a detailed explanation.
4. DELETE – This requests to removes the service method in the URL.
5. PATCH- This request is used to send a patch the service/ method to the URL.
6. OPTIONS- This request is used to get the information about the permissible and supported HTTP methods that can be used against the provided URL.Click here to know a detailed explanation
7. CONNECT- This request is used to create a connection with the requested resources.
8. TRACE- This request is used to debug the servers and provides the response.
ContentType: This specifies the type/format of the body request that needs to be. Select the options from the drop-down,
1. None- When None is selected, by default the type is selected as JSON.
2. JSON – Specifies the type in JSON, if the request that to be made is in JSON format, choose this option.
3. XML – Specifies the type in XML, if the request that to be made is in XML node, choose this option.
4. URLENCODED – Specifies the type in URLENCODED, if the request that to be made is in URLENCODED format, choose this option.
5. PLAINTEXT – Specifies the type as raw text, if the request that to be made is in RAW Text, choose this option.
6. Form-Data – This content type is used to send data as multipart form data, typically used for file uploads or when submitting form data in a way that mimics a web form submission
Accept: This specifies the type / format of the web method to accept while processing the URL. Select the options from the drop-down,
1. None- When None is selected, by default the type is selected as JSON.
2. JSON- Accepts the type in JSON, if the request that to be made is accepted in JSON.
3. XML – Accepts the type in XML, if the request that to be made is accepted in XML.
4. URLENCODED – Accepts the type in URLENCODED, if the request that to be made is accepted in URLENCODED.
5. PLAINTEXT – Accepts the type in PLAINTEXT, if the request that to be made is accepted in PLAINTEXT.
6. Form- Data – This indicates that the server is expected to return a response formatted as multipart form data. This is commonly used when the response includes multiple parts of data, such as files and form fields
Encoding: This specifies the encode format when the request needs to be encoded while calling the API. Select the options from the drop-down,
1. NONE,
2. ASCII
3. DEFAULT
4. BigEndianUnicode
5. Unicode
6. UTF32
7. UTF7
8. UTF8.
Authentication: Specifies the authentication protocol to be used when calling the API. The following protocols are supported:
None- Does not require any credentials to invoke the service.
BASIC- Username and password will be required to invoke the services.
Default Credentials- Login credentials will be required to invoke the services.
WINDOWS- Domain, username and password will be required to invoke the services.
TOKEN- Domain, username and password will be required to invoke the services.
Request Header: This enables to add a custom header that needs to be included in the URL segment.
InputParameters: This specifies the inputs / parameters that is used to request in the URL.
Body-Request: Specifies body request needs to be included in the URL. This field supports strings and string variables, JSON, XML, URLENCODED AND PLAINTEXT.
File -Transfer: Specifies the file path that needs to be uploaded/ downloaded as a resource from the URL.
Output: The output will be returned as a response to the respective URL provided.
Response codes
Each operation is followed by a HTTP response code that indicates if the request was successful or not. The response codes will be provided along with the output of the activity. Here are some typical response codes:
200 OK – Request accepted, response contains result.
201 CREATED – Resource has been created.
204 NO CONTENT – Request accepted, nothing to return.
404 NOT FOUND – No such resource.
405 METHOD NOT ALLOWED – Method cannot be performed against the resource.
Here’s an example of the activity is used in the workflow –
In the following example, I am using an open-source API with “POST” method. This API is used to access an open-source online library and using the “POST” method we are going to add book details to it.
Steps to execute a bot
1. Create a new solution.
2. Drag and drop the “REST” activity from the webclient automation feature.
3. The Rest wizard appears on the screen.
4. In the “Enter the URL” field, provide the value as “https://postman-library-api.glitch.me/books”.
a. This is the API to access the open-source library.
5. Choose the method as POST as we are sending the book details.
6. Choose the content type as “JSON”.
a. Since the body request is sent in “Json” format, we are opting the value as “Json”.
7. Moving to the “Body Request” and provide the value as below,
{
“title”: “Dune”,
“author”: “Roger Zelazny”,
“genre”: “fiction”,
“yearPublished”: 1965
}.
8. Click on the Save option to export the parameters to the activity.
9. Navigating to the “Text” property in the output section to declare a variable to view the output.
10. Add Write log activity from the “Notification” feature to view the output.
a. Here, enter the input string “Result”.
b. Choose the log level as “Info”.