APIs & Integrations

GDavis7
Member

Python can't get tickets from batch read

The closest thing i've found online related to my issue is the following ticket.
https://community.hubspot.com/t5/APIs-Integrations/Read-a-batch-of-tickets/m-p/487664

 

I'm using the hubspot-api-client package for python to do the batch read with the following code. I always get an empty list in the response which never contains an error (not even "Not Found" type error). However, the package may be hiding the error.

 

 

 

 

from hubspot import HubSpot
from hubspot.crm.tickets import SimplePublicObjectId, BatchReadInputSimplePublicObjectId

hubspot_api_client = HubSpot(<api key>)

id_list = [<ticket id 1>, <ticket id 2>, <ticket id 3>, <ticket id 4>]
inputs = [SimplePublicObjectId(id) for id in id_list]
batch_input = BatchReadInputSimplePublicObjectId(inputs=inputs, id_property='id', properties=['City', 'content', 'subject'])
hubspot_tickets = hubspot_api_client.crm.tickets.batch_api.read(batch_input)

 

 

 

 

I can use the same client object to retrieve each ticket successfully with get_by_id, but the batch always returns an empty list.

 

Permutations I've tried:

 

 

 

inputs = [{'id': SimplePublicObjectId(id)} for id in id_list]
inputs = [{'id': id} for id in id_list]
inputs = id_list

id_property = 'ticket_id'
id_property = 'ticketId'
id_property = 'hs_object_id'  # Name from get_by_id response properties

 

 

The response object i get in code is always as follows

 

{
  'status': 'COMPLETE',
  'results': [],
  'requested_at': None,
  'started_at': datetime.datetime(2022, 1, 13, 22, 45, 31, 173000, tzinfo=tzutc()),
  'completed_at': datetime.datetime(2022, 1, 13, 22, 45, 31, 231000, tzinfo=tzutc()),
  'links': None
}

 

I even tried the request using https://developers.hubspot.com/docs/api/crm/tickets example code and got the same empty list result, but it included a "Not Found" error.

 

What am i doing wrong?

0 Upvotes
1 Reply 1
TiphaineCuisset
Community Manager
Community Manager

Python can't get tickets from batch read

Hi @GDavis7 

 

Thank you for reaching out.

 

I want to tag some of our experts on this - @miljkovicmisa @JBeatty @Gonzalo do you have any thought for @GDavis7 on this? 

 

Thank you!

Best

Tiphaine


Saviez vous que la Communauté est disponible en français?
Rejoignez les discussions francophones en changeant votre langue dans les paramètres !

Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !


0 Upvotes