Sending a blob from Salesforce in a HTTP request?

Documentation says we can’t do this. So as the title says, is there a workaround to make this possible?


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

You can use the setBodyAsBlob(Blob someBlob) method on HttpRequest to send a raw blob in an HTTP request. If you need to send a mime multi-part request, then that’s harder as there’s no good way to glue together the string mime part headers and the binary data (you can at this point, base64 encode the payload to work around that).

Method 2

For servers that accept a Transfer-Encoding header, you can set the appropriate request header and send the data as Base64-encoded. Not all servers support this mode, however. It is also possible to send it as a multipart form message and set the Content-Transfer-Encoding header appropriately for servers that accept multipart form data with base64 encoding. If the server does not accept base64 encoding, then you cannot submit binary data to the server. This is because strings are native Unicode strings, and binary data doesn’t play well with Unicode.

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