Calling the API to run a bot
In this third step of the Running a bot through an API call tutorial, learn how to trigger a bot run by calling the IBM Robotic Process Automation API server with a body that contains an extra message.
Send data during the bot's request is a practice that you can use to accommodate the bot call to your business needs, by creating logics to manage bot calls.
This tutorial uses values that might differ from the ones that you must use in your API call. The following list defines which values that might differ:
Host
-
The endpoint to the API server hosting the IBM Robotic Process Automation platform.
-
If you are using IBM Robotic Process Automation as a Service,
Host
is{region}api.rpa.ibm.com
, where{region}
is one of the regions defined in Navigating to IBM RPA Control Center on IBM Robotic Process Automation as a Service.Example of host:
br1api.rpa.ibm.com
-
If you are using either IBM RPA on premises or IBM RPA on Red Hat® OpenShift® Container Platform,
Host
is the endpoint to the API server defined during the installation of the IBM RPA server.Example of host:
www.example.com
-
username
-
The user email to authenticate to the API server.
Example of username:
email@example.com
password
-
The password to authenticate to the API server.
Example of password:
passsword@123
tenantId
-
The unique ID that identifies a tenant on the IBM RPA server.
Example of tenant ID:
258jr555-9p74-123-45df-xxxxxxxxxxxx
token
-
The Authentication Token that is required to authenticate the API call to run the bot.
Example of token:
fjgk67Wenf_gkbnd_52Jklef365[...]hekd56Yj6kfl_HH
Before you begin
This step assumes that you completed the Authenticating to the IBM RPA API step and got the access token.
Procedure
-
Call the
/v2.0/workspace/{workspaceId}/projects/{projectUniqueId/bots/{botUniqueId}
endpoint. Use the following code do to call the bot:POST https://{region}api.rpa.ibm.com/v2.0/workspace/{workspaceId}/projects/{projectUniqueId}/bots/{botUniqueId} HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: application/json Authorization: Bearer {token} Content-Length: 64 Host: {region}api.rpa.ibm.com Connection: Keep-Alive User-Agent: Apache-HttpClient/4.5.5 (Java/16.0.1) { "additionalMessage": "Additional message here" }
-
Replace the following data:
- For
region
, enter the region of your tenant. - For
workspaceId
, enter the tenant ID. - For
projectUniqueId
, enter the project unique ID. - For
botUniqueId
, enter the bot unique ID. - Set a header Authorization to
Bearer {accessToken}
as returned from/token
request. - Enter an extra message as a body for the bot to log beyond the "Hello, world".
- For
Results
You can access the logs of the bot run on IBM RPA Control Center:
- Click Projects.
- Click the hello_world project.
- In the log_hello_world bot, click the vertical ellipsis button ⋮ > View jobs.
In the Status column, you see whether the bot's running succeeded or failed. You can see more information about this bot run:
- Next the Status, click the vertical ellipsis button ⋮ > Details.
- Click the Search button.
The following video shows the process to see the bot's logs:
What to do next
In this tutorial, you learned how to authenticate to the IBM RPA API server and run a bot through an API call. Although this tutorial is an example, you can expand on it. The following list defines a few expansion suggestions:
- You can hook your systems to the API to run bots according to your program rules.
- You can consume other IBM RPA’s API resources because now you know how to authenticate your requests.
- You can use this tutorial to run other bots.