RESTMessageV2's saveResponseBodyAsAttachment() only used for/with MID Server ?

Chris L5
Tera Contributor

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 ?)

 

3 REPLIES 3

Mike Patel
Tera Sage

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.

Nice ! I will give it a shot then. Will update once I get something working.  

Thank you for the "sanity check".  🙂

 

Hello Mike

 

Did you use the function to only attach one single attachment or did you iterate through multiple attachments and saving them?