Api: Get Most Recent Jobs

Hello I am just getting a bit confused and was wondering if anyone would be able to help; I am looking to get the 5 most recently attempted job status when I try using $filter=top it doesnt give todays jobs, is there a way to either restrict it to just show me todays jobs or the last x attempted jobs

Regards,
Sam Hedgecock

Are you getting too many? i think top=5 should work together with orderby

Also if you only want from today, you could filter like: CreationTime gt 2020-01-20T00:00:00Z

1 Like

Hello @bcorrea,
I am appearing to get previous jobs from past days but no recently executed jobs they all appear to be jobs that were executed via the online orchestrator and none that were executed via api.
I shall try with the start time to see if I can get that working
Would you be able to give me an example of how to use orderby as the odata documentation isnt the clearest

Regards,
Sam Hedgecock

Are you testing in swagger? The request would be like:
https://cloud.uipath.com/YOUR_DOMAIN/YOUR_SERVICE/odata/Jobs?$orderby=StartTime%20desc&$top=5

But if you want to also FORCE it to show only if it is from TODAY:
https://cloud.uipath.com/DOMAIN/SERVICE/odata/Jobs?$filter=StartTime%20gt%202020-01-20T00%3A00%3A00.00Z&$orderby=StartTime%20desc&$top=5

1 Like

Hello @bcorrea,
I am able to do the date filter now thanks but I am struggling to get that days jobs (more than 5) to be the most recent 5 even when using orderby=StartTime desc it has the same result as if I where to use orderby=StartTime
the whole request i am using is as follows:
https://platform.uipath.com/odata/Jobs?$top=5&$filter=StartTime gt “+str(yearint)+”-"+monthstr+"-"+daystr+"T00:00:00Z&$oderby=StartTime des

The str(yearint), monthstr and daystr are all variables to get current day values

Thanks again for your help

Regards,
Sam Hedgecock

Do you realize that if you want today, then your daystr variable must use yesterday right?

Is this correct? as when using yesterday ill get start times as such: 2020-01-20T15:04:08.46Z
but using today I get Stat times like: 2020-01-21T12:11:51.377Z

today is (21/01/20) for future reference

Regards,
Sam Hedgecock

yes, but if you want everything only from today, today started at 2020-01-20T00:00:0.00Z (midnight)

Surely that would be 24:00 of 20th not 0:00 of 21st? as as soon as it reaches 0:00 the day value goes forward and the time is then set to 0:00 or am I missing something within the documentation, as my view supports the times I demonstrated above.

Regards,
Sam Hedgecock

Well i guess it can be tested to be sure works well, but for me i thought it was like that… but maybe im wrong :slight_smile:

Yes I shall continue to test that, the only problem now is I still cant seem to order them using orderby=StartTime desc
it places them in asc order giving me the first 5 today rather than most recent 5
Thanks again for your help :slight_smile:

but is the result the same with and withour the orderby?

Yes the response remains the same with and without orderby

oh, so you have some problems there, did you test with fixed values already? cause orderby is working well for me…

Fixed values in terms of the date values? If so yes and it remains the same, but if you mean in regards to jobs I’m not sure how you would do this?
I am retrieving the response in Python using Requests library not sure if this would have anything to do with it by any chance?

Yes, in a matter of fact if your library is making a collection out of the result, maybe it does mess up the order, but i couldnt tell, im testing directly from swagger and i can ensure it is sorting accordingly…

Okay I shall continue to look into this specifically for python; thanks again for your help solved a great deal of my problems @bcorrea!

Regards,
Sam Hedgecock

1 Like