[SalesForce] How to overcome Maximum size of callout request or response in an external callout

Hi All I have a requirement were external webservice should handle more than 3MB of data. I am trying to send document/files to external system using callout. Is there any alternative way such as sharing a url for document/files? Can I use any other API apart from SOAP to achieve this? If use the callout in Batch apex/Future class can this be achieved?

Best Answer

I've faced the same issue time ago. In my case the files where stored as attachments.

I must warn you that sending the complete file body is a bad idea. You will not only face the size limit, also the time limit. Avoid that idea

My workaround to overcame that limit was to send the URL to get the attachment body by REST. Then the external service get the file content.

Sample:

curl https://na1.salesforce.com/services/data/v20.0/sobjects/Attachment/001D000000INjVe/body -H "Authorization: Bearer token"

The rest of the file metadata (name, etc) is send with the url.

More information about this here

Related Topic