In looking at the Apex Developer Guide, I see examples of how to use Apex REST to perform actions with Salesforce but I would like to know if Apex REST can interact with other REST APIs to pull binary data for copying documents from another source? I'm not sure if this would require some kind of encapsulation of the other REST API calls in an Apex script, but I'm trying to do it in a way to where the code is stored in Salesforce and calls the third-party REST API to transfer the data


Yes, you can call any endpoint you've authorized during an Apex REST transaction. Normal synchronous limits apply (6MB maximum response size). Some types of payloads may be more challenging than others because of Apex Code's limited support for binary data, but as long as the REST API you're trying to call is reasonably designed, it shouldn't be a problem. You can use the getResponseAsBlob method of HttpResponse to read the binary data, which you can then directly into an Attachment, Document, ContentDocument, etc.

Not the answer you're looking for? Browse other questions tagged or ask your own question.