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

Hi everyone,

I’m looking to see if there’s a way to get the last job ran on a machine, I have 8 machines assigned to different folders and would like to know the last job ran on one of these machines, if anyone could please help with the API request that I can use for this scenario?

Many Thanks
Mohamed

@Mohamed_Ouahbi

Welcome to the community

You can use get jobs api with filter on machine id and then get the latest out of the response

Please explore the swagger for details- <orchestratorURL>/seagger/index.html

https://docs.uipath.com/orchestrator/standalone/2022.10/api-guide/jobs-requests

Also you have a get jobs activity as well which can be used

Cheers

Hello @Mohamed_Ouahbi

  1. Obtain the Machine Key for the machine you’re interested in.
  2. Make a GET request to the Orchestrator API with the machine name in the filter, ordering by StartTime in descending order, and limiting to one result.
  3. Ensure proper authentication in the request header.
  4. Parse the response to extract job details, including Job Id, StartTime, etc.

Thanks & Cheers!!!

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

Cheers everyone thanks you for your help very much appreciate it :grinning:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.