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
-_--_- 

Getting "InternalServerError: Failed to write query result" when using Java and the Bulk API

Hi,  I have been spending a lot of time trying to export ContentVersion records OUT of salesforce.  I did not realize this would be such a challenge.

I was doing this in batch apex and it worked but quickly ran out of heap space as there are files larger than 12MB (largest file is 500MB).

I then went to the Java Bulk API as I was made aware that the same heap space limitations did not exist however for files that are large (not sure what the cut off is as of yet) I seem to be getting a reply of: InternalServerError : Failed to write query result".

Does anyone know how to get around this, or in general how to export (programmatically) contentVersion data as I am looking to pull it out of Salesforce and push it into another cloud based system.

Any help would be greatly appreciated as I have been at this for quite some time :(
Best Answer chosen by -_-
-_--_-
I was getting this error because I was querying for the VersionData field.  Once I removed this the query worked however I NEED the VersionData field in order to rebuild the file.  

Does anyone know how to query for VersionData, especially for files that are larger (several hundred MBs)?

All Answers

-_--_-
I was getting this error because I was querying for the VersionData field.  Once I removed this the query worked however I NEED the VersionData field in order to rebuild the file.  

Does anyone know how to query for VersionData, especially for files that are larger (several hundred MBs)?
This was selected as the best answer
-_--_-
Thanks for the  reply Gordon, unfortyunately I ran into a lot of issues getting FileExporter to work and ultimately it never ended up connecting to my org (I believe TLS was the issue).  :(
Gordon EngelGordon Engel
You could contact the developer and ask them to rebuild the tool with modern SSL libraries, since Salesforce does not support TLS 1.0 anymore.  Alternatively, you could try to do something with a proxy server to upgrade the security stack.

I'm sure there are other solutions out there.  You might look into a commercial data import/export tool that does everything you are trying to implement.
Mandeep Singh 146Mandeep Singh 146
Hi  -_- after lots of hard work and search im able to find a workaround for this issue. You can use force:recorddata similar as I've mentioning below:
<force:recordData aura:id="recordLoader"
    recordId="{!v.recordId}"
    fields="Id,Title,VersionData,PathOnClient"
    targetError="{!v.recordLoadError}"
    targetFields="{!v.fileRecord}"  
    recordUpdated="{!c.handleRecordUpdate}"                    
    />
for handling the multiple files you have to handle the recordId dynamically. You can do this by using the code below.
component.set("v.recordId",currentRecId);
var RecordId = component.get("v.recordId");
/component.find("recordLoader").set("v.recordId", RecordId);
 component.find("recordLoader").reloadRecord();

This worked for me hope this works for you as well.
Mark this as a best answer if its helpful.

Thanks
Mandeep