How to get ticket types from API?

im working on developing a custom topic where I wanted to populate the ticket types in a dropdown. I’m not sure which API to use to grab the ticket type. Can someone please help me on this?

Ticket Fields API can fetch you the details.
You can find the right field for Ticket type by filtering for the type attribute to select the one with default_ticket_type value.
Once you get the field’s ID (and may be cache this), you can hit View Ticket field API to get the list of choices and construct your dropdown.

let me work on this and let you know. I also wanted to get answers to below two questions. is that fine to answer here or need separate questions?

  1. wanted to know about the API which gives ticket type. because im working on a task.
  2. how to integrate the iparams.html file with the index.html?

kindly answer this two questions

The GET request to view a ticket should help you @sstudio, the response to the following command consists field: type

curl -v -u yourapikey:X -H "Content-Type: application/json" -X GET 'https://domain.freshdesk.com/api/v2/tickets/20'

Be sure to check out the documentation for additional information.

Explore these sample apps to understand the usage and flow, fetching Installation Parameters data is not different for JSON, HTML approaches.
If the ask is something different, please elaborate.

Hi, @tejakummarikuntla I tried with the above endpoint but I didn’t get any response. May I know what is 20 in the URL? I tried with the below endpoint and I got 20 can you please explain it?

https://sstudio.freshdesk.com/api/v2/tickets/20

@thanashyam asked me to use https://sstudio.freshdesk.com/api/v2/ticket_fields endpoint to grab all details and filter for default_ticket_type. I did that but how to get the field ID?. below is the sample response I got from the above endpoint. Thanashyam Raj asked to use the field ID to fetch the choices to populate on my app install page. is he pointing to the id field in the response below? if so, I tried invoking provided API with that id but I got 404 as a response.

kindly help me to fix this issue

    {
        "id": 84000344726,
        "name": "ticket_type",
        "label": "Type",
        "description": "Ticket type",
        "position": 3,
        "required_for_closure": false,
        "required_for_agents": false,
        "type": "default_ticket_type",
        "default": true,
        "customers_can_edit": false,
        "label_for_customers": "Type",
        "required_for_customers": false,
        "displayed_to_customers": false,
        "created_at": "2022-02-14T10:02:42Z",
        "updated_at": "2022-02-14T10:02:42Z",
        "choices": [
            "Question",
            "Incident",
            "Problem",
            "Feature Request",
            "Refund"
        ]
    }

84000344726 is the field id here.
You can hit /api/v2/admin/ticket_fields/84000344726 to get the list of choices.

1 Like

Thanks for your response @thanashyam here is the response from the endpoint shared. from this response, I have to label from the ‘choices’ field and populate those right? please confirm

{
"id": 84000344726,
"name": "ticket_type",
"label": "Type",
"label_for_customers": "Type",
"position": 3,
"type": "default_ticket_type",
"default": true,
"customers_can_edit": false,
"required_for_closure": false,
"required_for_agents": false,
"required_for_customers": false,
"displayed_to_customers": false,
"created_at": "2022-02-14T10:02:42Z",
"updated_at": "2022-02-14T10:02:42Z",
"archived": false,
"choices": [
    {
        "id": 1,
        "label": "Question",
        "position": null,
        "value": "Question",
        "parent_choice_id": 84000344726,
        "choices": []
    },
    {
        "id": 2,
        "label": "Incident",
        "position": null,
        "value": "Incident",
        "parent_choice_id": 84000344726,
        "choices": []
    },
    {
        "id": 3,
        "label": "Problem",
        "position": null,
        "value": "Problem",
        "parent_choice_id": 84000344726,
        "choices": []
    },
    {
        "id": 4,
        "label": "Feature Request",
        "position": null,
        "value": "Feature Request",
        "parent_choice_id": 84000344726,
        "choices": []
    },
    {
        "id": 5,
        "label": "Refund",
        "position": null,
        "value": "Refund",
        "parent_choice_id": 84000344726,
        "choices": []
    }
]

}

Yes, but I would suggest using label for displays purposes and when you are sending the data use value attribute.
Eg: <option value="{{ item.value }}">{{ item.label }}</option>
Though these contain the same data today, it might change later on.

1 Like

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.