Answered

Custom Fields in API call


I went into the "Admin" -> "Ticket Fields" page to add 2 new fields for tickets.  I then added these fields in my REST API call to create the ticket.  Based on another thread that I saw, I layed out the XML as follows

<helpdesk_ticket>
...


<custom_field>


<custom_field_1>value</custom_field_1>

<custom_field_2>value</custom_field_2>

</custom_field>



<helpdesk_ticket>

Unfortunately, this gives me a 500 HTTP response code.  Any idea what's going on?

Best Answer

I was able to get this to work. The screencast helped. Below's a curl template that might be helpful when trying this functionality out.

curl -u YOUR_API_KEY_HERE:X -H "Content-Type: application/json" -X PUT -d '{ "helpdesk_ticket": { "foo_field_160548": "Foo" }}' 'https://domain.freshdesk.com/helpdesk/tickets/4.json'

There are multiple ways to get the name of the custom field. One is using a ticket GET. Another is using the get all ticket fields API call.


Here is the other topic where this apparently worked: https://support.freshdesk.com/support/discussions/topics/3518


Hi Akshay


You may follow this screenr video, which will work fine for settings Custom Fields.


You must first create a Custom Field and set a value in a Ticket and view this field label in API and the use the PUT method to set a value for this ticket or other tickets, from here after


Do check the screenr and let me know if this helps ?


https://freshdesksupport.viewscreencasts.com/042f944fb3c644c08c581c60b096013b


Thanks and regards
Vijay

Works well. Need to download the chrome app 'PostMan' to monitor http traffic, then do a get on the url for one of the tickets to see the actual field name for the custom field.

Answer

I was able to get this to work. The screencast helped. Below's a curl template that might be helpful when trying this functionality out.

curl -u YOUR_API_KEY_HERE:X -H "Content-Type: application/json" -X PUT -d '{ "helpdesk_ticket": { "foo_field_160548": "Foo" }}' 'https://domain.freshdesk.com/helpdesk/tickets/4.json'

There are multiple ways to get the name of the custom field. One is using a ticket GET. Another is using the get all ticket fields API call.