Using the Post method
- Updated: 2025/02/13
Use the Post method actions from the REST Web Services package to create new resources in the URI.
This example uses endpoints from the Swagger Petstore sample API (Petstore) to demonstrate using Post method action to add data to the Petstore database.
Procedure
-
Create a new bot.
- Log in to your instance of the Control Room.
- On the left panel, click Automation.
- Click Create new > Bot.
- In the Create Task Bot window, enter the bot name.
-
Accept the default folder location: \Bots\
To change the default bot storage location, click Choose and follow the prompts.
- Click Create and edit.
-
Use the Post method
action to send data to a server. In this example, a new pet is added
to the store.
-
Double-click or drag the REST Web Services > Post method
action.
-
Enter the following URI:
https://petstore.swagger.io/v2/store/order
-
Proxy Configuration: Do one of the following:
- System: Under Authentication
Mode select the authentication. In this example, select
No Authentication as this endpoint does not require
authentication. Note: Typically endpoint requires authentication to ensure that only authorized applications are able to access the data. Select an appropriate authentication mechanism to allow access to the endpoint you want to access.
- Custom: This option allows you to configure custom proxy settings within the actions of REST Web Services. For more information, see REST Web Services package .
- System: Under Authentication
Mode select the authentication. In this example, select
No Authentication as this endpoint does not require
authentication.
-
Select the Content type that indicates in which format
the data is sent to. An incoming request can have an entity attached to it. The
Content type determines the type of the request. Some common Content types
include such as: application/x-www-form-urlencoded, JSON
(application/json), and XML (application/XML). In this example,
select JSON (application/json), copy and paste the following into the
Custom parameters field:
{ "id": 0, "petId": 0, "quantity": 0, "shipDate": "2022-04-20T22:08:11.977Z", "status": "placed", "complete": true }
-
Add
substitution: Allows you to enter variables in the REST
request body. A variable is a symbolic representation of data, and it
enables you to access a value without having to enter it manually wherever
you need it. For example, consider the following REST body
request:
In the above request body, you can replace the variables enclosed within double braces by clicking Add substitution and adding the required values.{ "name":"{{name}}", "email":"{{email}}", "status":"Active" }
-
Enter a time in milliseconds for the action to complete. You can leave it to
the default 60,000.
Tip: If required, you can set/unset options in the Advanced options. For more information on the Advanced options, see REST Web Services package.
-
Create the variable
Output
in the Assign the output to a variable field. For more information on creating a variable, see Create a variable.
-
Double-click or drag the REST Web Services > Post method
action.
-
Insert a Message box
action to see the response body.
- Double-click or drag the Log to file action.
-
In the Enter the message to display field, enter
$Output{Body}$
.
-
Click Save and then click
Run.
The bot displays the response in the message box.