Send attachment through REST API if Content-Type is Multipart/form-data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2022 07:09 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2022 08:16 AM
Hi,
have a look on these links
https://community.servicenow.com/community?id=community_question&sys_id=d905946cdb679b8067a72926ca96...
https://community.servicenow.com/community?id=community_question&sys_id=591eb718db16db00b61ff3231f96...
https://community.servicenow.com/community?id=community_question&sys_id=dcf3e30edb179300feb1a851ca96...
https://community.servicenow.com/community?id=community_question&sys_id=21619038dba5eb44f0612183ca96...
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2022 10:34 AM
Thanks for the suggestion links. I tried creating a Scripted REST API and a script include to convert the attachment in multipart/form-data. But it's still not working. Not sure how do I test it further.
I need to build a payload of Content-Type : multipart/form-data, which should have contain email and attachment.
I am able to do it with postman but tried every possible way. I even built a REST Action using Flow Designer to send Multipart but it's not working.
Could you please take a look at it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2022 08:05 PM
Hi,
in postman you are using form-data for POST
But I believe you need to use content body containing JSON from ServiceNow
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2022 02:20 AM