In order to create record in bulk using REST API, we using Composite Tree resource.

I'm trying to upload a bulk of content versions :

{"records" :[
  "attributes" : {"type" : "ContentVersion", "referenceId" : "ref1"},

  "attributes" : {"type" : "ContentVersion", "referenceId" : "ref2"},

Using endpoint: https://SandboxName.my.salesforce.com/services/data/v43.0/composite/tree/ContentVersion.

My questions are:

  1. The Response when everything handled fine is :
    "hasErrors": false,
    "results": [
            "referenceId": "ref1",
            "id": "0680Q0000006OSwQAM"
            "referenceId": "ref2",
            "id": "0680Q0000006OSxQAM"

But in Case we have one error on one of the files - I'm getting the next response:

"results": [
            "referenceId": "ref2",
            "errors": [
                    "statusCode": "SOME ERROR",
                    "message": "SOME ERROR",
                    "fields": [
                        "SOME FIELD THAT GET THE ERROR"
                } ]

BUT what happened to the other files that actually succeeded?

If there is one error on one of the files, Does it make it all fail? Even if they were succeeded?

If it does, Is there another method that I can upload a bulk of Content Version using REST API?

2.What about the size limit of Content Version in MB that I can upload with this approach? What is the max size that this API can handle with? I made a test and I succeed to upload files with a sum of 16 MB via this API - But I couldn't create a blob version more than this - It just caused my computer to stop working

1 Answer 1


Using the sObject Tree REST resource,

If an error occurs while creating a record, the entire request fails. In this case, the response contains only the reference ID of the record that caused the error and the error information.

This is because this resource is intended for creating a network of linked records. Because your objects are not linked together (you're simply trying to insert multiple records), you probably want to be using a different REST resource, such as sObject Collections. This would allow you to create multiple records in a single call, while specifying

   "allOrNone" : false,

to allow the records to fail or succeed individually and receive a result for each record you tried to create.

You'll probably also want to look at the page on how to Insert or Update Blob Data, which documents the size limitations you're looking for:

Using the SObject Basic Information or SObject Rows APIs, the maximum file size for uploads is 2 GB for ContentVersion objects and 500 MB for all other eligible standard objects. Using the SObject Collections API, the maximum total size of all files in a single request is 500 MB.

You can insert or update blob data using a non-multipart message, but you are limited to 50 MB of text data or 37.5 MB of base64–encoded data.

That documentation includes examples of how to send multipart messages to maximize the amount of data you can include in each request.

  • 1
    @Salvation ...finally!
    – Ayub
    Dec 19, 2018 at 15:01
  • @Ayub - Yep - I was just about to tag you on this post :) Thanks for your help
    – Salvation
    Dec 19, 2018 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .