PDPYRAS incident sorting using rget method and Python3

Using the official Python libraries, I want to obtain a list of 10 most recent Incidents using this:

Retrieves a list of 10 incidents in this account

print(“10 Incidents List”)
for ilist in session.rget(‘incidents’, params={‘limit’:10}):
print("%s | %s | %s"%(ilist[‘description’], ilist[‘incident_number’], ilist[‘created_at’]))

but as a result, dates in created_at field are showing NOT the most recent ones.

What should I do?

Hi Dennis,

You can add a sort_by parameter to the request to order the incidents from the most recent. Within pdpyras this would look like session.rget('incidents', params={'limit':10,'sort_by':'created_at:desc'}.