Maximum size of a SOAP API Response

I’m writing some Java code to retrieve attachments from Salesforce.

It seems I can query the Attachment object and retrieve the body column, but I’m concerned that I’ll blow a limit on the maximum size of a SOAP response.

SF has increased the attachment size limit to 20MB, so its possible that an attachment may be 20MB in size.

Will doing ‘select id, body from attachment’ blow a response limit? I have a recollection I’m limited to 10MB, but I can’t find the documentation that specifically mentions that.

Should I do an HTTP call to the Servlet.Download? url to retrieve the attachments outside of SOAP API? (Assuming I can inject the session id into the request).


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

There is no specific limit to the size of a SOAP response from Salesforce, (there is a 50Mb limit on the request size), in general the API tries to shape SOAP responses so that they’re not too big (as many client toolkits have no other options other than to deserialize the whole thing in memory), so you’ll notice for example your query that returns the body field will only return one row at a time. You should have no issue returning a 20Mb attachment body from a SOAP query call.

If you don’t want to take the base64 overhead of fetching attachments via the SOAP api, then consider using the REST API instead, which can return binary data without the base64 overhead, but please don’t use Servlet.Download, which is a UI endpoint.

In either case pay attention to HTTP level compression, which on typical attachments can decrease the payload size significantly.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x