A couple of months ago I created a simple web service that uses UiPath’s API in order to return the status of the latest job that was run. It worked fine for weeks but now suddenly it’s not returning the latest job that was run, but it keeps returning a job that ran a few days ago. Does anyone know what might cause this?
I know there is an update on how to connect 3rd parties to the API, might that be causing this problem?
Also, I have followed the documentation on how to connect a 3rd party application as is shown here but I can’t get it to work. So if someone has successfully used this method I would really appreciate a step by step explanation on how to get it to work.
And here is the new code I tried out for OAuth 2 Authentication - it doesn’t work and does not return a token, so the method I’m using is probably wrong:
The order in which jobs are returned from odata/Jobs endpoint without any OData parameters isn’t technically defined. If you’d like to find out the status of the last job that was run, try ordering by StartTime desc or EndTime desc, for example /odata/Jobs?$top=1&$orderby=StartTime desc should return the last job that has started. Use StartTime if you’d like to include running jobs which do not have an EndTime property set. If you’re interested in completed jobs only, successful or failed, use EndTime.
Thank you for your help. It looks like the response limit is 1000 items. Your code works but it keeps returning the oldest job that ran and not the most recent one. So the ‘desc’ ordering is not working. This is now my enpoint: ${URL}/Jobs?$top=1&$order=EndTime desc . Changing desc to asc makes no difference. Any idea on how I can get the most recent job? I don’t have much experience in this area. Thank you in advance.
Thank you @vasile.bujac, now it returns just one job, but it still returns the oldest one instead of the latest job. I tried ‘orderby’, but that didn’t return anything. I also tried ‘order_by’ and that returned the oldest job again.
The very same API is used by Orchestrator UI, it should work. Can you sign in to your Orchestrator tenant, go to the “Jobs” page, open up your browser’s developer tools (F12 usually), go to network tab, sort by Start/End time in descending order by pressing on the grid column and see what request is sent.
This is what I’m getting, you can see the query used for ordering is $orderby=EndTime desc