Skip to main content
I want to upload a file to content version using Rest API. As of now i achieved to do using REST API with java code. Code is uploading till 35 MB single file and no more than that. Code is throwing 400 status code.

Please suggest me its possible to upload a file more than 100+MB file. If its  YES, then where i got stuck. looking forward from team if any one faced same situation.

.

 
4 answers
  1. Mar 17, 2020, 12:50 PM
    Hi Sunil,

    You must be hitting the following limit

    "You can insert or update blob data using a non-multipart message, but if you do, you are limited to 50 MB of text data or 37.5 MB of base64–encoded data and that is the reason you are not able to load the content version via Rest api"

    https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_insert_update_blob.htm⌗inserting_a_contentversion

    Did you try using any other way of loading other than using Java cide? This should be possible using any tools capable of generating multipart POST requests (e.g. Curl, Fiddler, C⌗/.NET client applications, etc.).

    In multipart message the first part of the request message body contains non–binary field data such as the Description or Name. The second part of the message contains the binary data of the file that you're uploading.

    Example for creating a new Document via curl:

    curl https://na1.salesforce.com/services/data/v23.0/sobjects/Document/ -H "Authorization: Bearer token" -H "Content-Type: multipart/form-data; boundary=\"boundary_string\"" --data-binary @newdocument.json

    Example request body for creating a new Document

    This code is the contents of newdocument.json. Note that the binary data for the PDF content has been omitted for brevity and replaced with “Binary data goes here.” An actual request will contain the full binary content.

    --boundary_string

    Content-Disposition: form-data; name="entity_document";

    Content-Type: application/json

    {

    "Description" : "Marketing brochure for Q1 2011",

    "Keywords" : "marketing,sales,update",

    "FolderId" : "005D0000001GiU7",

    "Name" : "Marketing Brochure Q1",

    "Type" : "pdf"

    }

    --boundary_string

    Content-Type: application/pdf

    Content-Disposition: form-data; name="Body"; filename="2011Q1MktgBrochure.pdf"

    Binary data goes here.

    --boundary_string--

    Example response body for creating a new Document

    On success, the ID of the new Document is returned.

    {

    "id" : "015D0000000N3ZZIA0",

    "errors" : [ ],

    "success" : true

    }

    If this is failing with other apps as well, we know you are hitting the limit. Otherwise there could be an issue with Java code

    Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. Thank you!

    Anudeep

     
0/9000