- 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
03-15-2017 10:28 PM
Can you remove the 'Content-Type' header and try?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2017 10:25 AM
Sorry we get still error as
{"code":"UNSUPPORTED_MEDIA_TYPE","message":"Content type was not provided or is not supported"}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2017 10:04 PM
What is the content-type of the attachment that you are trying to send? You can check the content type of each attachment in sys_attachment table.
Specify that content type in the 'Content-Type" header and try. And I am not sure what the "mime-type" header is for, may be remove it and try as well
- 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 .