How to find if an Orchestrator job is in a Pending state on a particular Machine template using REST API?

How to find if an Orchestrator job is in a Pending state on a particular Machine template using REST API?

Introduction

Understanding whether a job is in a 'Pending' state on a specific Machine template is important for efficient process tracking and management. This information helps with making necessary status changes or eliminating any hindrances causing delays. This process can be automated through the REST API, thereby saving time and effort. The API provides an ability to interact with UiPath Orchestrator data via a third-party application and fetch job statuses in a more streamlined and efficient manner.

Resolution

To find if an Orchestrator job is in a Pending state on a specific Machine template using REST API:

  1. Adjust the following Orchestrator REST API request based on your needs and run it individually for each Orchestrator folder that needs monitoring.

image.png

Method: GET

[For On-Premise and Automation Suite Orchestrator]

GET https://REPLACE_WITH_ORCHESTRATOR_HOSTNAME/odata/Jobs?$filter=((contains(Release/Name,'REPLACE_WITH_RELEASE_NAME')) or (contains(Reference,'REPLACE_WITH_PROCESS_NAME'))) and ((ProcessType eq 'Process')) and (Machine/Name eq 'REPLACE_WITH_MACHINE_TEMPLATE_NAME') and ((State eq 'Pending'))&$top=100&$expand=Robot,Machine,Release&$orderby=CreationTime%20desc

[For UiPath Cloud Orchestrator]

GET https://cloud.uipath.com/REPLACE_WITH_ORGANIZATION_NAME/REPLACE_WITH_TENANT_NAME/orchestrator_/odata/Jobs?$filter=((contains(Release/Name,'REPLACE_WITH_RELEASE_NAME')) or (contains(Reference,'REPLACE_WITH_PROCESS_NAME'))) and ((ProcessType eq 'Process')) and (Machine/Name eq 'REPLACE_WITH_MACHINE_TEMPLATE_NAME') and ((State eq 'Pending'))&$top=100&$expand=Robot,Machine,Release&$orderby=CreationTime%20desc
Sample:
https://laptop-******/odata/Jobs?$filter=((contains(Release/Name,'Office365GetMail')) or (contains(Reference,'Office365GetMail'))) and ((ProcessType eq 'Process')) and (Machine/Name eq 'Client_ID_Machine_Template') and ((State eq 'Pending'))&$top=100&$expand=Robot,Machine,Release&$orderby=CreationTime%20desc

  1. Provide the following Headers:
  • Authorization: Bearer YOUR_ACCESS_TOKEN
  • Accept: application/json
  • X-UIPATH-FolderPath: YOUR_ORCHESTRATOR_FOLDER_NAME

Outcome

If there is at least one job in 'Pending' state for a specific Process and Machine template name, you will see a result like below.


If there are no jobs in 'Pending' state for the specific Process and Machine template name, the outcome will be as follows:


Note: Replace the placeholders (text in the capital letters with underscores) with your specific details.