POST

The POST Method can be used to create a new resource/data to the collections of resources.
The POST method can be used to post the required data to the resource and returns the
response.

Use Case

The following use case helps you to understand how the POST method from the REST activity is
utilized to get the token as a response to the given URL. The input is an API which is used to correct
the misspelled words. This model is known as "Spell Check" from RobilityAI model in Manager.
This API requires a token to access the URL, thus we are using the token URL to access the
bearer type values and use the same token as authentication to use the spell check model.
Let's get into an example to see how this POST method works.

Steps to execute a bot

The following example helps you to get the token from the provided URL using the POST
method. Here we are using the POST method as we are sending the UID & TenantID
embedded with the URL as the details to be posted. The response should be returned as
token number with the bearer type.

1.       Drag and drop the REST activity from the webclient automation feature.

2.       Double click on the activity and open the REST form.

3.       Enter the URL from which the details need to be
invoked and executed. Here it is
https://cognitiveservices.robility.ai/token?uid=772e780b-6ba5-4313-9e09-b6a37a6a
8699&tenantid=741E3787-E3A3-47D2-BF59-2F483BC42CCC

4.       Choose the method as POST as we are going to post the details(i.e., UID & Tenant ID
embedded with the URL)to get the token details.

5.      Click on the Invoke option to get the token details.

6.       Click on Save option to export the parameters to the activity.

7.       Declare a variable in the text from output properties panel. Here it is “pt”

8.       Add a writelog activity to get the response in the output window.

9.       Enter the input string as “pt” and Log level as “info.”

10.   Execute the activity.

The bot executes the activity, uses the POST method and gets the token for the given
API URL. Now we are going to use the spellcheck AI model which helps us correct any
wrong spellings.

Before we use the spell check model, we need to embed the UID & TenantID from the
TOKEN URL to the Spell check  URL. Follow the below steps to use the Spell check URL,

1.       Copy the generated token to a notepad.

2.       Now let’s consider the token URL taken above, which is https://cognitiveservices.robility.ai
/token?uid=772e780b-6ba5-4313-9e09-b6a37a6a8699&tenantid=741E3787-E3A3-47D2-
BF59-2F483BC42CCC

3.       Then let’s take the URL copied from the spell check and paste it against the TOKEN URL
to do the spell check. Here how it looks,
https://cognitiveservices.robility.ai/textract/spellcheck/text?uid=772e780b-6ba5-4313-9e09-
b6a37a6a8699&tenantid=741E3787-E3A3-47D2-BF59-2F483BC42CCC

4.       Navigate to the request header, this header is used to post the details to be requested
along with the URL while processing the service. Now, enter the key as “Authorization” and
the value as the token retrieved from the previous action. We need to add the key word 
“Bearer” before the token.

5.       Next navigate to the Body-Request and enter the incorrect word for which the check has
to be made.

6.       Click on invoke to get the response.

7.       We can see the right spelling in the output box.

8.       To export this to the workflow, click on save.

9.       Declare a variable to the text box of the output segment. Here it is “post”.

10.   Drag and drop a writelog activity to the workflow.

11.   Enter the input string as “post” and the log level as “info”.

12.   Execute the activity and we can see the right spelling displayed in the output box.

The bot executes the activity and gives the correct spelling in the output box.