Attachments + custom fields not working

I’m trying to add a ticket with both an attachment and a custom field. Because of the attachment, I have to submit as multipart/form-data instead of json. But because of this, I’ve not been able to successfully submit the custom field.

What format for custom fields will work?

I’m using Guzzle and am trying to submit the data as follows:

array
(
[multipart] => array
(
[0] => array
(
[name] => ‘attachments[0]’
[contents] => {resource}
)
[1] => array
(
[name] => ‘custom_fields[project_type]’
[contents] => ‘Website Project’
)
[2] => array
(
[name] => ‘description’
[contents] => ‘

This is a test ticket.


)
[3] => array
(
[name] => ‘email’
[contents] => ‘apitest@example.com’
)
[4] => array
(
[name] => ‘name’
[contents] => ‘API Test’
)
[5] => array
(
[name] => ‘phone’
[contents] => ‘123-456-7890’
)
[6] => array
(
[name] => ‘priority’
[contents] => 1
)
[7] => array
(
[name] => ‘requester_id’
[contents] => 12035089240
)
[8] => array
(
[name] => ‘source’
[contents] => 2
)
[9] => array
(
[name] => ‘status’
[contents] => 2
)
[10] => array
(
[name] => ‘subject’
[contents] => ‘Testing the API’
)
)
)

The response I get is:
{“message”:“We’re sorry, but something went wrong.”}

hey @onehat,

could you please clarify the following?

  • are you using a Freshworks app and trying to create a ticket from the app? if yes, how are you doing it?

  • Are you using an external app that uses guzzle to interact with Freshdesk API to create a ticket?

I am using an external app that uses Guzzle to interact with the Freshdesk API to create a Ticket.
I successfully created a Ticket with no attachment and a custom field, submitting as json. I also successfully created a Reply with an attachment using multipart/form-data. But I cannot seem to create a Ticket with attachment AND custom field using multipart/form-data.

@onehat

if my understanding is correct you were able to create a ticket without attachment and with custom fields, but when you try it with an attachment it fails? if that is the case kindly send us the payload and the file that you’re trying to attach, we’ll try it from our end!

if you want to know how to work with custom fields using API, here is a link for your reference https://support.freshdesk.com/support/solutions/articles/216548-create-and-update-tickets-with-custom-fields-using-api

Hey @onehat, Were you able to have your query resolved?

This topic was automatically closed after 13 days. New replies are no longer allowed.