Send attachment through REST API if Content-Type is Multipart/form-data

aks4
Tera Contributor

Hi

I am trying to integrate Freshdesk with ServiceNow using REST API. We have a requirement to create a ticket along with attachment. We have configured a REST Message and a post method to do so. I am able to create a ticket without attachment using normal content-type as application/json. We have to send the attachments also from the incident to Freshdesk ticket using the same method. 

Now the issue is, we have to send the data as Content-type - Multipart/form-data

I have tried changing application/json to multipart/form-data but its not being sent

Alternatively, I have created a REST Action using Flow Designer to send the same data but the same error 400.

Freshdesk supports attachment picked up from Local machines as File type.

I am able to create the ticket with attachment using postman. I checked the code and it uses variable new formdata() which does not work inn ServiceNow script include or business rule.

Appreciate your suggestions

 

6 REPLIES 6

Eric Smith
Tera Expert

aks4, have you thought about using a 3rd party tool to make the integration? it's just an option, but i think it might be useful in your case - will save you a lot of time and effort. we opted for such an integration solution for one of our projects and all is still working perfectly - more than a year later.

Kim Sullivan
Tera Guru

@aks4 - Did you ever get a solution to this?  I'm trying to do the same thing but with FreshService.