Extracting the Name of Zendesk Custom Fields through APIs in Python

1 Kommentare

  • Ahmed Zaid
    Community Moderator

    Hi Uwemoqode,

    The tickets api only returns field ids. To get field titles, you need to query the ticket field endpoint and cross reference the results.

    I choose to query it once, save it as hashable, and use it to provide field titles.

    Append this snippet to your code (python 3.10+):

    # Save ticket fields id and title in a dict
    ticket_fields = {}
    for ticket_field in zenpy_client.ticket_fields():
      ticket_fields[ticket_field.id] = ticket_field.title

    # add the title attribute to the previously generated dict of ticket custom fields
    for custom_field in custom_fields:
      custom_field['title'] = ticket_fields[custom_field['id']]

    print(custom_fields) # [{'id': 123, 'value': 'bar', 'title': 'foo'}]

    Now you can see the id, value, and title.


Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.

Powered by Zendesk