3

By providing following uri and by using following Request Body, we can insert a single record in a sObject

uri: /services/data/v36.0/sobjects/sObject
Request Body : {
"field1" :"value1",
"field2" :"value2"
}

But, how to insert multiple records in an object using post method in workbench? Could any one please suggest me.

3

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

/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"
    }]
}
  • @SKumaran you're welcome .. – Ratan Paul May 24 '16 at 6:38
0

I don't think it is possible to create/update multiple records in a single call via the REST API.

Please follow the below SFSE link to know more about this.

SFSE Link - Is it possible to insert multiple records in Salesforce using cURL at the same time?

0

I don't have the perfect solution about this but for the REST API, I have found an Excellent tutorial where we learn how to automate REST API/Web API/SOAP/OAuth/OData Service integration in SSIS. It includes JSON Source Connector, XML Source Connector and REST API Task. Check it out..Hope it Helps:)

https://zappysys.com/blog/howto-import-json-rest-api-power-bi/

Your Answer

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