Return binary file from scripted rest api

Drct1234
Mega Expert

Hello,

Is there a way to return a binary file as output from a scripted rest API?
The file is returned from another endpoint.
I want to achieve something similar to what GlideSysAttachment().getContentStream(sys_id) and response.getStreamWrite allow.
In this case, the source file is the response from a RESTMessageV2 GET call.
I can't find a way to set the response body from the binary content.

Thanks!

1 ACCEPTED SOLUTION
5 REPLIES 5

Thanks Hitoshi.
I found a solution that saves the binary file to a SNOW attachment (using saveResponseBodyAsAttachment) and then follows the approach you mention.
I posted the link in this post.