We are doing freskdesk integration and want to do this callout - add Note to ticket

This integration require multipart-form data request type. Checked many blogs and stackover flow question-answer but not getting much clarity.

If you see on above link, this request can accept array of attachment along with few more properties/parameters in httpRequest.

Most of the examples available for multipart httpRequest are only about single attachment and without any other parameters.

Below is the curl code given at freskdesk portal for similar request-

curl -v -u yourapikey:X -F "attachments[]=@/path/to/attachment1.ext" -F "body=Hi tom, Still Angry" -F "notify_emails[][email protected]" -X POST 'https://domain.freshdesk.com/api/v2/tickets/20/notes'

how do we create a similar http Request in apex?

I have tried changing Http Request header paramter with content-type to 'multi-part/formdata' req.setHeader('Content-type', 'multipart/form-data'); but where do we set array of attachment and how object of attachment will look like similar where to set othr parameter

  • 1
    The linked answer should help you. You can attach any arbitrary number of arguments using the code provided by the accepted answer. If you're still stuck, please edit your question to include the code you've tried so we can better assist you.
    – sfdcfox
    Commented Dec 27, 2023 at 21:00


Browse other questions tagged .