Get the latest job details using UiPath APIs

Hi,
I am using UiPath Cloud Orchestrator. I am trying out the APIs to get details of teh Jobs. I understand that using the $top param, we can filter the number of jobs that we want to retrieve. If I assign 3 to $top, I get the first three jobs run by the robot. Is there a way to get the last three jobs i.e the latest jobs performed?
I used the following API:
https://cloud.uipath.com/[ company]/[Tenant]/odata/Jobs?$top=3&$filter=Release/Name eq ‘abc’

Thank you

Hi,

Please try like below. you have to use order by to get the latest jobs. if you want only today’s jobs please refer the below thread it could guide you better. thanks.

https://cloud.uipath.com/[ company]/[Tenant]/odata/Jobs?$top=3&$filter=Release/Name eq ‘abc’&orderby=StartTime%20desc

Hi, thank you. Orderby did not change the response that I get. I get the same data

Hi,

if you use order by descending so that you will get latest top 3 jobs for your filter earlier. please try and let us know or you can use the today date so that you can get latest jobs for today. thanks.

1 Like

For further references to @kirankumar.mahanthi1 solution Please see UiPath Documentation that covers using OData Clauses [$top, $filter, $expand, $select, $orderby, $skip] with examples.

You have to indicate which Field you want to order by and if not Ascending, to indicate you want it Descending to reverse the order. (Default is Ascending)

1 Like

Hi @sherlin.s,

I was just setting up an example when you deleted your post so I’m going to finish responding anyways in case it helps you or someone else that stumbles on the topic.

In my environment I have ran 4 Jobs with the following start times over the last year or so.

2020-11-20T09:11:00.91Z
2020-11-20T09:12:15.387Z
2021-10-21T18:03:43.097Z
2021-10-21T18:03:44.073Z

If I run the following GET request and Parameters
{{orchestrator_url}}/{{account_name}}/{{tenant_name}}/odata/Jobs?

$filter=(ProcessType eq 'Process')&$top=10&$select=StartTime`

I get the default Sort order (Ascending)

{
    "@odata.context": "https://cloud.uipath.com/{{account_name}}/{{tenant_name}/orchestrator_/odata/$metadata#Jobs(StartTime)",
    "@odata.count": 4,
    "value": [
        {"StartTime": "2020-11-20T09:11:00.91Z"},
        {"StartTime": "2020-11-20T09:12:15.387Z"},
        {"StartTime": "2021-10-21T18:03:43.097Z"},
        {"StartTime": "2021-10-21T18:03:44.073Z"}
    ]
}

The same query but this time we will add in $orderby=StartTime asc and we get the same results in the same order.

$filter=(ProcessType eq 'Process')&$top=10&$orderby=StartTime asc&$select=StartTime
{
    "@odata.context": "https://cloud.uipath.com/{{account_name}}/{{tenant_name}}/orchestrator_/odata/$metadata#Jobs(StartTime)",
    "@odata.count": 4,
    "value": [
        {"StartTime": "2020-11-20T09:11:00.91Z"},
        {"StartTime": "2020-11-20T09:12:15.387Z"},
        {"StartTime": "2021-10-21T18:03:43.097Z"},
        {"StartTime": "2021-10-21T18:03:44.073Z"}
    ]
}

Adjusting the $orderby to descending with $orderby=StartTime desc You can see that it has reversed the order with the most recent Start time being the first value.

$filter=(ProcessType eq 'Process')&$top=10&$orderby=StartTime desc&$select=StartTime
{
    "@odata.context": "https://cloud.uipath.com/{{account_name}}/{{tenant_name}}/orchestrator_/odata/$metadata#Jobs(StartTime)",
    "@odata.count": 4,
    "value": [
        {"StartTime": "2021-10-21T18:03:44.073Z"},
        {"StartTime": "2021-10-21T18:03:43.097Z"},
        {"StartTime": "2020-11-20T09:12:15.387Z"},
        {"StartTime": "2020-11-20T09:11:00.91Z"}
    ]
}
1 Like

Hi @codemonkee ,
I realised the mistake in my API request, I used ‘orderby’ instead of ‘$orderby’.

Thank you

1 Like

Hi,
Thank you very much for the detailed example. Helped me understand the the concept better.

Thanks for updating us on your resolution! Glad we could help stir you in the right direction.

Very informative Tim. thanks for your response. earlier post it was my mistake i missed the $ symbol.

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