File content corrupted when sending attachments using RESTMessageV2 API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2017 08:18 AM
I am trying to send attachments from ServiceNow to a third party application using the RestMessageV2 API. The POST request is successful but the binary attachment data appears to be corrupted when it's delivered to the third party application for files like pdf, jpg, etc... I can send pure text files without issue. The corruption only occurs when sending from ServiceNow. I can send the same request with postman without any issues. Unfortunately, base64 is not supported by the third party application so it must be binary.
Here is an example of the POST request I built in ServiceNow:
HTTP Headers:
Content-Type: multipart/form-data; boundary=93a1d467-2dr3-9872-a65b-1d2f645d1c36
Cache-Control: no-cache
Body/Content:
--93a1d467-2dr3-9872-a65b-1d2f645d1c36
Content-Type: application/bin
Content-Disposition: form-data; name=bin; filename="test.jpg"; filename*=utf-8''test.jpg
${file}
--93a1d467-2dr3-9872-a65b-1d2f645d1c36--
For simplicity, right now I am using the Attachment API (doc here) to retrieve the binary data and populate the ${file} parameter. I have tried the setRequestBodyFromAttachment method but I need to build a multi-part message so that won't work. If you have any ideas or direction, I would greatly appreciate your feedback!
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2017 07:11 AM
Hi Nicholas,
Are you sending the base64encoded data for the attachment to the third party application?
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
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
09-28-2017 07:58 AM
Thank you for your reply. I am trying to send binary data. Base64 is not supported by the third party application.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2017 01:46 AM
I have the exact same problem - were you able to find a way to fix this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2017 09:08 AM
Have you reviewed the following code example: