setRequestBodyFromAttachment - How does it work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2016 05:02 PM
Hi everyone,
I want to know that how does setRequestBodyFromAttachment method works? I know how to use it but I just want to know what actually happens at the backend?
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('post');
request.setEndpoint('http://myendpoint');
request.setRequestBodyFromAttachment('attachment-GUID');
request.setMIDServer('my_mid_server');
var response = request.execute();
var httpResponseStatus = response.getStatusCode();
so when I fire the above code, MID server will pick it up, fetch the attachment and POST it to the endpoint.
My question is - how does that POST happens?
- Is it using base64 encoding?
- Or file is streamed to the endpoint?
- Or is it sent as a multiform data content?
- Or something else happens?
Thanks in advance.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2016 10:23 AM
Hi all - anyone with any inputs please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2016 06:27 AM
Hi there,
setRequestBodyFromAttachment :- sends base 64 encoded file. So your parameter should be a encoded file.
Hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2017 02:40 PM
Hi,
I am looking for the same requirement where I have to pass the attachment from Servicenow to Jira. Can you please help with the complete code?
Thank You,
Richa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2019 09:17 AM
Hi,
here is the detailed solution for this thread,
Sending attachments (ServiceNow to 3rd party)
1. Outbound Rest message- Need to ask for an endpoint of the 3rd party. Configure HTTP headers If any.
2. Use this Rest message in the business rule to send attachments
a. Call the rest message and simply send the binary content of the attachment to the request body using function request.setRequestBodyFromAttachment('<attachment sys_id>');
(RESTMessageV2 - setRequestBodyFromAttachment(String attachmentSysId) )
Screenshot of the business rule
Please Marked this question as the answered to close the thread.
Regards,