function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mitul ThumarMitul Thumar 

Using Apex Rest API Send files/Attachment to third party.

Hello All,

Can we send file/Attachment data to a third party using Apex rest api if the file/attachment size is bigger, more than 12MB?

Working fine for less than 12MB.

We have many files/attachment are more than 12MB and we are facing salesforce limitation.

Open for any discuss or any suggestion are welcome.

Thanks
Mitul

 

Suraj Tripathi 47Suraj Tripathi 47
Hi Mitul,
Greetings!!

Normal apex code has a 6 MB (memory) or heap size limit. If you are using the Asynchronous apex (i.e batch jobs, @future methods)  these have a 12 MB limit size and custom-coded inbound email handlers have a 36 MB Limit size.
You won't be able to push more than that limit size from the apex code. Even if the size is less or if the file is binary and you might have to base64-encode it before sending it through API.
To send more than 12MB files, you have to encode the base64 data into a BLOB.
You can send the encoded BLOB using Rest API.
example-
EncodingUtil.base64encode(data);
If this helped you please mark it as the best answer. 
Thanks and Regards 
Suraj Tripathi
Mitul ThumarMitul Thumar
Thanks, @Suraj for the reply, sorry to say its not working, same hitting governor limits. Can you please provide a sample code if you have?