Multipart request to 3rd party
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2025 10:31 PM
I have a requirement to send a multipart request having an input Json and input file. The input file is a compressed zip file in ServiceNow and expectation at third party is to have type string and binary format for the file as in screenshot. Also, the testing from Postman is successful as it allows a direct upload of the file from system. Is this feasible from ServiceNow and will the file content have any issue being compressed zip file?
Please help with the script/approach for this if feasible
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2025 11:15 PM
Hello @Parvathy B1
You can use below code to send attachment in binary format -
var sa = new GlideSysAttachment();
var StringUtil = new GlideStringUtil();
//Get the base64 encoding of the attachment
var binData = sa.getBytes(singleattachmentsysid);
var encData = GlideStringUtil.base64Encode(binData);
Now for multiple just add loop.
i hope this answers your queries.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2025 11:20 PM
hello @Parvathy B1
I had also explored "Attachment API" in REST API explorer few days back and it does return the "binary format precisely"
Refer screenshot -
You can use this as well for exact.
This is a demonstration video on Attachment API - https://youtu.be/VqCxt1vSvIE?si=-3dfGQ71OLFpMYMJ
In case that helps.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2025 11:22 PM
handling sending of multi-part is somewhat complex
check these links
Multipart/form-data attachment pusg using Rest API from Snow->Jira
Outbound REST - Multipart/form-data
REST API attachments Transfer to JIRA
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader