- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 12:40 AM
Hello Experts,
How can we configure Outbound Rest message to send attachment to 3rd party(cloudplus) which later can be used in business rule?
Or is there other way of writing business rule for the same.
Do we need to encode it into Base64 before sending?
I am bit confused.
Any Help would be appreciated.
Thanks
Neeraj Sharma
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2017 02:19 AM
finally i am able to successfully send attachment to 3rd party and viceversa via rest.
Points to Remember.
Sending attachments (serviceNow to 3rd party)
1. Outbound Rest message- Need to ask for a 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
And you will see Magic happens.
Receiving attachments (3rd party to serviceNow)
1. Go Rest API explorer > select Attachment API in API name and explore all the APIs available (Get, Post, Delete)
For are two ways of making Post request :-
a) https://yourinstance.service-now.com/api/now/attachment/file
b) https://dev33253.service-now.com/api/now/attachment/upload
table_name = Table name ( incident for above case)
table_sys_id = Unique Id of the record to which attachment needs to be inserted.
file_name = name of the attachment.
In HTTP header you need to send Content-Type Also (Not mandatory but always good to give).
Postman Screenshots
Hope this will be helpful.
Thanks
Neeraj sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 03:44 PM
The easiest way is to use the RestMessageV2 in your script and use setRequestBodyFromAttachment(). It will put the binary of the attachment into your request body, no converting needed.
Docs: RESTMessageV2 - setRequestBodyFromAttachment(String attachmentSysId)
Also posted here:
Re: OutBound Rest Message with a attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2017 05:14 AM
Hi Jarod M
Thanks for setRequestBodyFromAttachment().
That worked like a superstar
Please can you help me in sending attachment from 3rd party to servicenow.
I found two POST attachment APIs,
1. /api/now/attachment/file
2. /api/now/attachment/upload
But I do not know how to use them.
FYI 3rd party will be sending binary data?
Thanks
Neeraj

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2017 11:00 AM
I typically use the /api/now/attachment/file version.
Docs article: Attachment API - POST /now/attachment/file
tl;dr version:
- Put the full binary file in the request body
- Put the content type in the 'content-type' header
- Put the ServiceNow destination table_name, table_sys_id, and file_name into the query string
- POST to https://instance.service-now.com/api/now/attachment/file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2019 01:56 AM
Hi Neeraj,
Could you please suggest how can we send attachment from 3rd party tool to servicenow without using attachment api.
As we need to give only one api for incident creation and file attachment .
Thanks
Gunjan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2021 12:52 PM
Hi Neeraj,
We have the same case, would you mind helping me out with how you fix this case.
Your help will be much appreciated. Thank you in advance.