Unable to read custom property from a Ticket

Issue: Unable to retrieve custom property from API.

# Function to get a property from a ticket
def get_ticket_property(ticket_id, property_name):
 url = f'{BASE_URL}/crm/v3/objects/tickets/{ticket_id}'
 response = requests.get(url, headers=headers)
 response.raise_for_status()
 ticket_data = response.json()
 print(ticket_data);
 return ticket_data.get('properties', {}).get(property_name)

#Call
property_name_to_read = 'test' # Replace with the actual property name you want to read
 ticket_property_value = get_ticket_property(ticket_id, property_name_to_read)

Output:
mac@emailAutomation % python3 test1.py
Using ticket ID: 3678394578
{'id': '3678394578', 'properties': {'content': None, 'createdate': '2024-07-25T07:13:06.244Z', 'hs_lastmodifieddate': '2024-07-26T14:16:54.770Z', 'hs_object_id': '3678394578', 'hs_pipeline': '0', 'hs_pipeline_stage': '1', 'hs_ticket_category': None, 'hs_ticket_priority': None, 'subject': 'Ticket2'}, 'createdAt': '2024-07-25T07:13:06.244Z', 'updatedAt': '2024-07-26T14:16:54.770Z', 'archived': False}
Property "test" not found in the ticket.

I can see some properties but not the custom properties for a particular ticket.

It is a ticket-activity property.

The property exists when I check it on Hubspot.

The property is not null on Hubspot.

I am not able to retrieve custom ticket property from Hubspot API.

#Function to get a property from a ticket
def get_ticket_property(ticket_id, property_name):
 url = f'{BASE_URL}/crm/v3/objects/tickets/{ticket_id}'
 response = requests.get(url, headers=headers)
 response.raise_for_status()
 ticket_data = response.json()
 print(ticket_data);
 return ticket_data.get('properties', {}).get(property_name)

#Call: Read the 'test' property from the ticket
 property_name_to_read = 'test'
 ticket_property_value = get_ticket_property(ticket_id, property_name_to_read)
Output:

Retrieved ticket ID: 3678394578
{'id': '3678394578', 'properties': {'content': None, 'createdate': '2024-07-25T07:13:06.244Z', 'hs_lastmodifieddate': '2024-07-26T14:16:54.770Z', 'hs_object_id': '3678394578', 'hs_pipeline': '0', 'hs_pipeline_stage': '1', 'hs_ticket_category': None, 'hs_ticket_priority': None, 'subject': 'Ticket2'}, 'createdAt': '2024-07-25T07:13:06.244Z', 'updatedAt': '2024-07-26T14:16:54.770Z', 'archived': False}
Property "test1" not found in the ticket.

I can see some already existing properties but not the custom properties for a particular ticket in the output.

Background:

  • It is a ticket-activity property.
  • The property exists when I check it on Hubspot.
  • The property is not null on Hubspot.

Hubspot Screenshot:

Hey, @arpitbajpai :waving_hand: Let’s step back and simplify our test a bit. Can you get it to work as expected when you test from the dev doc? Or when using Postman?

I set up a quick test using my dev portal:

  • I created two custom Ticket properties and gave them values on a specific Ticket

  • Made a request to the Get Ticket by ID endpoint
    Request

    curl --request GET \
     --url 'https://api.hubapi.com/crm/v3/objects/tickets/1555709794?properties=test%2Ctest1&archived=false' \
     --header 'authorization: Bearer YOUR_ACCESS_TOKEN'​
    

    Response

    HTTP 200
    
    {
     "id": "1555709794",
     "properties": {
     "createdate": "2023-04-13T22:25:41.685Z",
     "hs_lastmodifieddate": "2024-07-31T15:57:50.072Z",
     "hs_object_id": "1555709794",
     "test": "hello",
     "test1": "arpitbajpai"
     },
     "createdAt": "2023-04-13T22:25:41.685Z",
     "updatedAt": "2024-07-31T15:57:50.072Z",
     "archived": false
    }​
    

Can you try the same and share your request and response here using the dev doc example, please?

Thanks! — Jaycee

Hello Jaycee Lewis, Thanks for your message. Is it not possible to retrive all the properties as JSON response without putting every id in the request object?

Also, how do we go about setting the property using API?

Hey, @arpitbajpai :waving_hand: You have to specify which properties you want returned. Unfortunately, there is not an option to return a record, or records, with “all” properties included by default. — Jaycee