I’m try to get the value of the custom property that i’ve added in the Ticket properties. I can able to get the json response from the Ticket APi and display all of the ticket number(objectId) but when i try to display the value of the custom property that i created i’m getting “KeyError: ‘ref_num’”
Json response:
{‘portalId’: 43680158, ‘objectType’: ‘TICKET’, ‘objectId’: 1888262026, ‘properties’: {‘ref_num’: {‘versions’: [{‘name’: ‘ref_num’, ‘value’: ‘423011’, ‘timestamp’: 1694045255743, ‘sourceId’: ‘2069329’, ‘source’: ‘INTEGRATION’, ‘sourceVid’: [], ‘requestId’: ‘6514e376-91b6-4080-9786-2245a30d04bb’, ‘useTimestampAsPersistenceTimestamp’: True}], ‘value’: ‘423011’, ‘timestamp’: 1694045255743, ‘persistenceTimestamp’: 1694045255743, ‘source’: ‘INTEGRATION’, ‘sourceId’: ‘2069329’, ‘updatedByUserId’: None}}, ‘isDeleted’: False}
{‘portalId’: 43680158, ‘objectType’: ‘TICKET’, ‘objectId’: 1888290979, ‘properties’: {‘ref_num’: {‘versions’: [{‘name’: ‘ref_num’, ‘value’: ‘423009’, ‘timestamp’: 1694045254773, ‘sourceId’: ‘2069329’, ‘source’: ‘INTEGRATION’, ‘sourceVid’: [], ‘requestId’: ‘5d051f4d-3eb8-4950-b08f-6db274dec6d0’, ‘useTimestampAsPersistenceTimestamp’: True}], ‘value’: ‘423009’, ‘timestamp’: 1694045254773, ‘persistenceTimestamp’: 1694045254773, ‘source’: ‘INTEGRATION’, ‘sourceId’: ‘2069329’, ‘updatedByUserId’: None}}, ‘isDeleted’: False}
My code (Display ticket number (working)
url = "https://api.hubapi.com/crm-objects/v1/objects/tickets/paged?properties=ref_num"response = request("get", url)jsonTickets = response.json()for ticket in jsonTickets['objects']: print(format(ticket['objectId']))**********Displays:18882620261888290979*********
My code (Display ref_num (not - working)
url = "https://api.hubapi.com/crm-objects/v1/objects/tickets/paged?properties=ref_num"response = request("get", url)jsonTickets = response.json()for ticket in jsonTickets['objects']: print(format(ticket['ref_num']))******Error: print(format(ticket['ref_num']))~~~~~~^^^^^^^^^^^^^^^KeyError: 'ref_num'**********
How do i get the value of “ref_num” to display. My apologies if i’m new to python. Appreciate the help. Thanks