Returning latest meeting booked with Python custom script

Hello,

I would like to return latest meeting booked for customer so I could then change its status afterwards. With below code I was able to return booked meeting, however it is not ordered to show most recently booked.

import hubspot
from pprint import pprint
from hubspot.crm.objects.meetings import ApiException

API_KEY = "xxx"
def main(event):
 # Use inputs to get data from any action in your workflow and use it in your code instead of having to use the HubSpot API.

 client = hubspot.Client.create(access_token=API_KEY)

 try:

 api_response = client.crm.objects.meetings.basic_api.get_page(limit=1, archived=False)
 meeting_dict = api_response.results[0]
 pprint(api_response)
 meeting_id = meeting_dict.id

 except ApiException as e:
 print("Exception when calling basic_api->get_page: %s\n" % e)

 #email = event["inputFields"]["email"]
 # Return the output data that can be used in later actions in your workflow.
 return {
 "outputFields": {
 "meeting_id": meeting_id
 }
 }

Is there a method to order results of the query?

Regards,

Damian.

Hi, @DPodraza :waving_hand: Thanks for reaching out. Hey @JBeatty @tominal, do you have any experience with the approach @DPodraza is taking?

One other place to investigate is utilizing the Search API, which allows for adding a “sorts” rule to the request body. And I’ll defer to our Python experts in the community to take a look at your specific issue.

{
 "sorts": [
 {
 "propertyName": "createdate",
 "direction": "DESCENDING"
 }
 ]
 }

Best,

Jaycee