- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2017 03:24 PM
I searched through the community and could not find sample code to send file attachment through REST Outbound from servicenow .
I tried the below code so far with no luck
var r = new sn_ws.RESTMessageV2();
r.setHttpMethod('post');
r.setEndpoint("endpoint");
r.setRequestHeader("Accept","application/json");
r.setRequestHeader('Access-Token',accesstoken);
r.setRequestHeader('Content-Type','multipart/form-data');
r.setRequestHeader('Mime-Type','application/pdf');
r.setRequestBodyFromAttachment('f8cfa45ddbe5f200ddfc7e7dbf9619f6');//attachment Id
var response = r.execute();
var responseBody = response.getBody();
gs.debug(responseBody);
var httpStatus = response.getStatusCode();
The error I get is as follows
{"code":"INVALID_MULTIPART","message":"An invalid multipart was specified"}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2017 05:43 PM
Its been confirmed by ServiceNow that they do not support multipart form data .The only solution is either use Mid server or create own proxy server where you can send as Binary Stream .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2017 02:16 PM
I didn't like the answer, so I found out an alternate method: putting your form data into a raw text format.
Convert your key: value pair to a raw data format of key=value with an & inbetween value and the next key:
key=value&nextkey=nextvalue&thirdkey=thirdvalue
Then place this into the Content portion of your message
ALSO set a HTTP Header of:
Content-Type: application/x-www-form-urlencoded
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2018 05:28 AM
Thanks Brian. Your approach helped. I needed to pass values to BMC (Outbound REST message) as a Content-Type as application/x-www-form-urlencoded and was able to pass it successfully following your approach.
Thank you very much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2020 11:17 AM
This was helpful, but also discovered that you will likely need to run any variables through a URI Encoder process before submitting.
It just so happened one of our test values had a "&" character in it, and this was causing a problem when populating the content block when sending the POST. It would treat the character as a break to the next key/value pair.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2020 06:58 AM
Hi,
I love the creative thinking using the 'Content' field - great solution! The official ServiceNow solution for this, I guess, is using Flow Designer. The REST step allows you to simply select "form encoded" and then provide the name-value pairs below. I am using this method successfully in automating webinar operations on the ON24 event platform from my ServiceNow instance.
Kind regards
Ralf Schnell
Senior Platform Evangelist, ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2020 07:35 AM
Hi Ralf,
Glad ServiceNow came with excellent solution.
But is it poosible to send From_encoded Request type in rest message without using integrationHub.
Thanks,
Vivek|LinkedIn