Orchestrator API's: Get the latest job ran on a machine

Hi @Mohamed_Ouahbi ,
Thanks for reaching out to UiPath comminity.

You can make a GET request to the Orchestrator API’s /odata/Jobs endpoint with appropriate filters to find the last job for a specific machine.

  • Get API Key:
    • Before making API requests, you need to obtain an API key from your Orchestrator instance. You can create an API key in Orchestrator under the “Settings” > “API Access” section.
  • Make a GET Request:
    • In UiPath, you can use the “HTTP Request” activity to make the API request. Set the method to “GET” and provide the Orchestrator API URL with the /odata/Jobs endpoint.
  • Set Filters:
    • To find the last job for a specific machine, you need to apply filters. You can use the $filter query option to filter the jobs by machine name and sort them by start time in descending order.

You can try using this URL : https://your-orchestrator-url/odata/Jobs?$filter=Release/Name eq ‘YourReleaseName’ and MachineName eq ‘YourMachineName’&$orderby=StartTime desc&$top=1

  • Set API Key in Headers:
    • In the “Headers” section of the HTTP Request activity, add an “Authorization” header with the value “Bearer YourAPIKey”. Replace YourAPIKey with the API key you obtained.
  • Parse the Response:
    • Use the “Deserialize JSON” activity to parse the response and extract the information you need, such as the job status, start time, and any other relevant detail.

You can give this a try.

Regards,
@pratik.maskar