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

I am using cURL to insert data into salesforce. It works with single record but I need to insert multiple records at a time. Is it possible to do so and is it possible via a REST interface?

Answer

You can’t insert multiple rows in a single call in the rest api, you need to use the bulk api.

You can develop custom REST wrapper webservice through APEX language of sfdc to get this set up

@RestResource(urlMapping='/insertcontact/*')

global with sharing class Mycontacts{

 @HttpPost
  global static List<Contact> doPost(List<Contact> lstcnts){
      insert lstcnts;
      return lstcnts;
   }

}

This is pretty raw version.You can follow best practices and track successful Ids and failed records .

If there are two much of records i would suggest you to use BULK API of sfdc as the REST API has size limitations and all apex governor limits apply

Edit

As per latest update this is now possible with tree API provided

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_composite_sobject_tree_flat.htm

Attribution
Source : Link , Question Author : Vineeth , Answer Author : Mohith Shrivastava

Leave a Comment