0

I have written a batch job to push Open Case record every one hr from Salesforce to External system using REST API. I need to Encrypte the data and push it to the external system. Below is the Class structure which I am building to push the record. Now the issue is if I have less than 1MB file I don't have any issue. When I have bigger files I get the following error.

First error: Invalid data. Input data is 1833299 bytes, which exceeds the limit of 1048576 bytes.

    String reqJSONStr = Json.serializePretty(Caselist);
    Blob blobJsonRequest = Blob.valueOf(reqJSONStr);
    /////////////// Encryption Code //////////////// 
    String cptKey = (CryptoKeyVal.Key_Value__c).trim();
    Blob newcryptoKey128 = EncodingUtil.base64Decode(cptKey);
    Blob encryptedData = Crypto.encryptWithManagedIV('AES128', newcryptoKey128, blobJsonRequest);
    ////////////////////////////////////////////////////// 
    req.setBody(EncodingUtil.base64Encode(encryptedData));
    HttpResponse res = new Http().send(req); 


 public class CaseString
 {        
   String case_Subject{get;set;}
   String case_Description{get;set;}
   String contact_fname{get;set;}
   String contact_lname{get;set;}
   String case_no{get;set;}
   String priority{get;set;}
   List<ContentVerCls> files{get;set;}                     
 }
 class ContentVerCls
 {
   String FileName;
   String Description;
   Blob Content;
 }

I need some suggestions on how I can push bigger files from Salesforce to External System without any issue.

2
  • 1
    It's a hard limit in Salesforce, and documented at that: developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/… You might want to chunk your data in SF and reassemble on the other end but given the heap limit of 6MB it is a PITA anyway. Why not just push the case ID to the external System and have it query SF Rest api to download actual info about case and associated files?
    – zaitsman
    Commented May 23, 2022 at 5:27
  • @zaitsman thanks for your reply. Is there any other method I can send the data+File in an encrypted format and not hit the size issue.
    – Tamil
    Commented May 24, 2022 at 11:22

0

You must log in to answer this question.

Browse other questions tagged .