- 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
08-27-2020 07:42 AM
See my response which includes how to do so. (3rd reply to the question)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2020 07:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2020 07:48 AM
I couldn't able to convert into raw format.
would you please help me to get the raw converted format?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2020 07:53 AM
You have to manually do that. As stated:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2020 09:04 AM
Thank you, Brian.