3
/services/data/v36.0/sobject/ObjectName
and 
{
"name" : "some name",
"Description" : "Some Description"
}

By using above uri and request body we can insert a single record in object with post method in workbench or in postman also.

But how to insert multiple records in object using same post method?

4

Create Multiple Records using rest API

Documentation

While the SObject Tree resource can be used to create nested records, you can also create multiple, unrelated records of the same type. In a single request, you can create up to two hundred records. In the request data, you supply the required and optional field values for each record, each record’s type, and a reference ID for each record, and then use the POST method of the resource. The response body will contain the IDs of the created records if the request is successful. Otherwise, the response contains only the reference ID of the record that caused the error and the error information.

We need to use below end point url

/services/data/v34.0/composite/tree/Account/

And request body will be something like this

{
"records" :[{
    "attributes" : {"type" : "Account", "referenceId" : "ref1"},
    "name" : "SampleAccount1",
    "phone" : "1111111111",
    "website" : "www.salesforce1.com",
    "numberOfEmployees" : "100",
    "industry" : "Banking"   
    },{
    "attributes" : {"type" : "Account", "referenceId" : "ref2"},
    "name" : "SampleAccount2",
    "phone" : "2222222222",
    "website" : "www.salesforce2.com",
    "numberOfEmployees" : "250",
    "industry" : "Banking"
    },{
    "attributes" : {"type" : "Account", "referenceId" : "ref3"},
    "name" : "SampleAccount3",
    "phone" : "3333333333",
    "website" : "www.salesforce3.com",
    "numberOfEmployees" : "52000",
    "industry" : "Banking"
    },{
    "attributes" : {"type" : "Account", "referenceId" : "ref4"},
    "name" : "SampleAccount4",
    "phone" : "4444444444",
    "website" : "www.salesforce4.com",
    "numberOfEmployees" : "2500",
    "industry" : "Banking"
    }]
}
  • 1
    Ratan awesome post.Can you close this post also.It has same question. – Mr.Frodo May 24 '16 at 6:07
  • @Mr.Frodo thanks I have posted in other question as well. – Ratan Paul May 24 '16 at 6:12
  • Hi @Ratan, I have a doubt what is the need of using referenceId? Can you explain me please...... – KS Kumaar May 24 '16 at 6:48
  • 2
    @KSKumar referenceId used to identify the records. For example if you are inserting 4 records and 2 are successful and 2 records hit error. So for newly created record you can identify using RecordId but for rest 2 record which are failed you can identify using referenceId. The response body will contain the IDs of the created records if the request is successful. Otherwise, the response contains only the reference ID of the record that caused the error and the error information – Ratan Paul May 24 '16 at 6:53
  • Let us continue this discussion in chat. – KS Kumaar May 25 '16 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.