RESTMessageV2's saveResponseBodyAsAttachment() only used for/with MID Server ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2020 01:28 PM
Looking over the Documentation.. I am not entirely sure I understand when RESTMessageV2's saveResponseBodyAsAttachment() can be used.
It mentions "When you use this function with a REST message that is sent through a MID server..."
But to me.. I interpret that as meaning that it's not ONLY for use via MID Server..
However, if it can be used say.. for example.. with a REST Service on some other Server (Not ServiceNow).. and that REST Service is using Python to return a File within the Rest Response...
Then how would saveResponseBodyAsAttachment() understand the payload within the Response and know how to parse it ? It is able to introspect things sufficient to "just figure it out". ?
This article hopefully shows that you dont need to use MID.. and that "it just works".. but I am not sure how it would be able to make use of a seemingly endless variety of payloads within a HTTP Response.
https://developer.servicenow.com/blog.do?p=/post/saving-restmessagev2-responses-as-attachments/
(maybe I am overthinking this ?)
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2020 05:08 PM
saveResponseBodyAsAttachment() can be used whenever you want to save response as attachment and maybe attach it to specific record.
I used in one of my requirements where user click on button that calls api and attaches the response to ticket.
It was direct so no Mid server.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2020 03:34 AM
Nice ! I will give it a shot then. Will update once I get something working.
Thank you for the "sanity check". 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2023 10:21 AM
Hello Mike
Did you use the function to only attach one single attachment or did you iterate through multiple attachments and saving them?