Freshdesk API2 ticket_type error on CURL PUSH

​I’m getting issues with the ticket_type field. Appreciate if anyone who’s figured this out could advise of what I’m doing wrong. I’ve tried it as a custom field, prefixing with cf_ etc but no joy.

    curl -u MY_API_KEY:X -H "Content-Type: application/json" -X POST -d '{ "description": "My Testing API", "subject": "My Testing API", "email": "testingAPI@invalidemail.com", "priority": 1, "status": 2, "custom_fields" : {  "category" : "Sales"}, "ticket_type": "Sales Enquiry" }' 'https://mycompany.freshdesk.com/api/v2/tickets'
Error that comes back
    {
    "description": "Validation failed",
    "errors": [{
    "field": "ticket_type",
    "message": "Unexpected/invalid field in request",
    "code": "invalid_field"
    }]
    }

However,

curl -u MY_API_KEY:X -X GET https://mycompany.freshdesk.com/api/v2/ticket_fields

returns

[
   {
      "id":"XXXXXXXXXXX",
      "name":"requester",
      "label":"Search a requester",
      "description":"Ticket requester",
      "position":1,
      "required_for_closure":false,
      "required_for_agents":true,
      "type":"default_requester",
      "default":true,
      "customers_can_edit":true,
      "label_for_customers":"Requester",
      "required_for_customers":true,
      "displayed_to_customers":true,
      "created_at":"2015-02-18T22:16:32Z",
      "updated_at":"2020-04-14T10:16:20Z",
      "portal_cc":false,
      "portal_cc_to":"company"
   },
   {
      "id":5000627913,
      "name":"subject",
      "label":"Subject",
      "description":"Ticket subject",
      "position":2,
      "required_for_closure":false,
      "required_for_agents":true,
      "type":"default_subject",
      "default":true,
      "customers_can_edit":true,
      "label_for_customers":"Subject",
      "required_for_customers":true,
      "displayed_to_customers":true,
      "created_at":"2015-02-18T22:16:32Z",
      "updated_at":"2020-04-14T10:16:21Z"
   },
   {
      "id":5000627914,
      "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":"2015-02-18T22:16:32Z",
      "updated_at":"2020-04-14T10:16:21Z",
      "choices":[
         "Sales Enquiry",
         "Billing Enquiry",
         "Problem",
         "Feature Request",
         "Disconnection",
         "Other"
      ]
   },
   {
      "id":5000627915,
      "name":"source",
      "label":"Source",
      "description":"\"Ticket"
​

@Steven_Gregg,
Hope you are doing good! Welcome to the community!
there is no field called ticket_type in creating the ticket, kindly refer to this link for more reference.

Hope it helps :slight_smile:

Thanks

Hi Thantos,

It must be a custom field as my GET call returned the following :-

{“id”:5000627914,“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”:“2015-02-18T22:16:32Z”,“updated_at”:“2020-04-14T10:16:21Z”,“choices”:[“Sales Enquiry”,“Billing Enquiry”,“Problem”,“Feature Request”,“Disconnection”,“Other”]}

I’ve also tried
curl -u MY_API_KEY:X -H “Content-Type: application/json” -X POST -d ‘{ “description”: “My Testing API”, “subject”: “My Testing API”, “email”: “testingAPI@invalidemail.com”, “priority”: 1, “status”: 2, “custom_fields” : { “ticket_type”: “Sales Enquiry”} }’ ‘https://mycompany.freshdesk.com/api/v2/tickets

@Steven_Gregg,
I got it, kindly take a look at this link for more reference on how to create a ticket with custom feild

Hope it helps

Hi Santhosh,

Thank you for your response. That link was what I was already using as a template.

My other custom fields work, it’s just this particular one that wont.

As I stated. I’ve already tried:-

I’ve also tried

curl -u MY_API_KEY:X -H “Content-Type: application/json” -X POST -d ‘{ “description”: “My Testing API”, “subject”: “My Testing API”, “email”: “[testingAPI@invalidemail.com](mailto:testingAPI@invalidemail.com)”, “priority”: 1, “status”: 2, “custom_fields” : { “ticket_type”: “Sales Enquiry”} }’ ‘https://mycompany.freshdesk.com/api/v2/tickets’

@Steven_Gregg,
What is the type of that custom field (text/dropdown) ?
if it is the dropdown, then you need to pass the correct value to get it populated.

Hope it helps :slight_smile:

Thanks

1 Like

Hi Santosh, thanks for reply and sorry for delay over the holidays.

In my OP, I demonstrated what the curl GET returns. AFAIK it’s a dropdown. My curl POST call to populate with “Sales Enquiry” matches one of the dropdown options.

 {
      "id":5000627914,
      "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":"2015-02-18T22:16:32Z",
      "updated_at":"2020-04-14T10:16:21Z",
      "choices":[
         "Sales Enquiry",
         "Billing Enquiry",
         "Problem",
         "Feature Request",
         "Disconnection",
         "Other"
      ]
   },

@Steven_Gregg - By any chance were you able to find a fix for this issue you reported?

I was having the exact same issue. Turns out this field is called “type” and it is not a custom field.

The following curl would work:

curl -u MY_API_KEY:X -H “Content-Type: application/json” -X POST -d ‘{ “description”: “My Testing API”, “subject”: “My Testing API”, “email”: “[testingAPI@invalidemail.com](mailto:testingAPI@invalidemail.com)”, “priority”: 1, “status”: 2, “type”: “Sales Enquiry” }’ ‘https://mycompany.freshdesk.com/api/v2/tickets’

Figured it out through trial and error.