Managing automation jobs in UiPath Orchestrator is essential for maintaining a smooth and efficient workflow. UiPath offers robust activities to start and stop jobs programmatically, providing you with greater control over your automation processes. In this blog post, we will explore how to use UiPath to start and stop jobs in Orchestrator.

Prerequisites

Before we begin, ensure you have the following:

An active Orchestrator API key or credentials.

UiPath Studio installed.

Access to UiPath Orchestrator.

image 30

The UiPath.WebAPI.Activities package installed via the Manage Packages window.

 Starting a Job in UiPath Orchestrator

Starting a job in UiPath Orchestrator involves sending a request to the Orchestrator API to initiate a specific process on a designated robot. Here’s how to do it:

1. Set Up Orchestrator Connection

Configure the Orchestrator HTTP Request with your Orchestrator URL and provide the necessary authentication details.

Open UiPath Studio and create a new process.

In the Activities panel, search for the Orchestrator HTTP Request activity and drag it into your workflow.

2. Create HTTP Request to Start Job:

   – Drag and drop the “HTTP Request” activity from the `UiPath.WebAPI.Activities` package.

   – Configure the HTTP Request activity as follows:

     – EndPoint: `https://{your-orchestrator-url}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs`

     – Method:POST

     – Headers: Add headers for authentication (Bearer Token) and content type (application/json).

     – **Body: Add the JSON body containing the details of the job to start.

     “`json

     {

       “startInfo”: {

         “ReleaseKey”: “YOUR_RELEASE_KEY”,

         “Strategy”: “Specific”,

         “RobotIds”: [YOUR_ROBOT_ID],

         “NoOfRobots”: 0

       }

     }

     “`

3. Configure Output

Set the output of the HTTP Request activity to capture the response, for example, startJobResponse.

4. Check Job Status

Extract the job ID and status from the response.

Use the Deserialize JSON activity to parse the JSON response.

Stopping a Job in UiPath Orchestrator

Stopping a job involves sending a request to the Orchestrator API to halt a running job. Follow these steps:

1. Get a Job ID

Obtain the job ID of the running job you wish to stop. This can be retrieved using the Get Jobs activity or from the response in the previous example.

2. Create HTTP Request to Stop Job

Add headers for authentication (Bearer Token).

Drag and drop the HTTP Request activity into your workflow.

Configure the HTTP Request activity as follows:

Endpoint: https://{your-orchestrator-url}/odata/Jobs({jobId})/UiPath.Server.Configuration.OData.StopJob

Method: POST

Headers:

3. Configure Output

  • Set the output of the HTTP Request activity to capture the response, for example, stopJobResponse.

4. Check Stop Status

Extract and display the status of the stop job request.

Use the Deserialize JSON activity to parse the JSON response.

Using the Start Job and Stop Job Activities

Alternatively, you can use the built-in Start Job and Stop Job activities for a more streamlined approach.

Starting a Job

  1. Drag the Start Job activity into your sequence.
image 31

2. In the Properties panel, input the following:

  • Process Id
  • Job Id

You can obtain the Process Id and Job Id from your Orchestrator.

image 32

Stopping a Job

Drag the Stop Job activity into your sequence.

image 33

In the Properties panel, input the following parameters obtained from Orchestrator:

  • Orchestrator Folder Path
  • Job Name
  • Strategy: Choose either Kill or Stop

Conclusion

Starting and stopping jobs in UiPath Orchestrator using HTTP requests provides a flexible way to control your automation processes. By integrating these activities into your workflows, you can dynamically manage job execution and enhance the robustness of your automation solutions. Remember to handle errors and exceptions gracefully to ensure smooth operations.

Categorized in: