Run a UiPath Job using Python (Community Edition)

Ishmeet Bindra
3 min readMay 8, 2020

**This tutorial will only work if you have a Cloud Orchestrator (community) account. Please refer to this article in case you are looking for a guide for Enterprise Orchestrator.

This is a 4 step tutorial explaining how to run a job using Cloud Orchestrator API and Python. This tutorial assumes that you know how to connect the UiPath robot to the orchestrator and have set up some processes in it.

The response from Orchestrator is in JSON format so we have also used the python’s JSON package to parse it. To make requests we are using python’s requests library.

Step 1- Get an Authentication Token.

Orchestrator issues temporary bearer tokens which are nothing but some secret value that server issues to identify you. These are short-lived so they must be regenerated at regular intervals. In the case of Cloud Orchestrator, these tokens are good for 24 hours.

Before moving on we need to head over to https://platform.uipath.com/ and then navigate to the ‘services’ page. From there select the option of ‘API Access’ from the kebab menu of your service.

Extract Client and User ID from API Access Option

From here extract ClientID, UserKey, Tenant Logical Name, and Account Logical Name and save these in the following variables (this is just for demo purpose, in the ideal case you should encrypt these and save them in a config file).

Code Snippet #1

The above shown is the minimum information required for you to generate the bearer token. Use the above information to create the class object of CommunityOrchestratorAPI class.

Code Snippet #2

Using the Orchestrator object, call the following function of the CommunityOrchestratorAPI class.

Code Snippet #3

Please note that within headers you have to define the X-UIPATH-TenantName key otherwise UiPath won’t be able to link it to your account.

Now we have generated a Bearer Token for our process.

Step 2- Get Process ID.

Process ID (also known as Release Key) is a unique way of identifying any process on orchestrator. We will use the process’s name to identify and retrieve its ID. Use the Orchestrator object to call the getProcessID() function and pass the process name as argument.

Code Snippet #4

Step 3- Get a Robot ID.

Now we need to identify the robot on which we want to run our process. For this, we will use the robot’s name. Use the Orchestrator object to call the getRobotID() function and pass the robot name as argument.

Code Snippet #5

Step 4- Run the Bot.

After gathering all the information now we simply run the bot by calling the runJob() function via the Orchestrator object.

Code Snippet #6

A few things to note here-

Strategy: It defines how we want to run this process. ‘Specific’ means we want to run this process on a specific robot. ‘Dynamic’ means we want to run the process on any of the available bots on the environment.

InputArguments: It defines the input arguments of the process. leave it blank if the process does not have any arguments.

Code and Conclusion.

So this is how we run a bot using Orchestrator API via python. The entire code is down below. Knock yourself out!!!

Code Snippet #7

For more please refer to Orchestrator API Guide.

--

--