You need to sign in to do that
Don't have an account?

How to create bulk record using rest API?
Example for creating an Opportunity :
Example request body for multiple record newrecord.json file :
Error in .net Code : 400 bad request
Error in Workbench : errorCode: METHOD_NOT_ALLOWED
message: HTTP Method 'POST' not allowed. Allowed are HEAD,GET
curl https://na1.salesforce.com/services/data/v20.0/sobjects/Opportunity/ -H "Authorization: Bearer token" -H "Content-Type: application/json" -d @newrecord.json -X PATCHExample request body newrecord.json file :
{ "Name":"FFNEw","CloseDate":"2015-05-02","StageName":"Prospecting","Probability":10 }My ASP.net code :
using (WebClient client = new WebClient()) { client.Headers.Add("Authorization", "Bearer " + token.access_token); client.Headers.Add("Content-Type", "application/json"); var request = (HttpWebRequest)(HttpWebRequest.Create(token.instance_url + "/services/data/v20.0/sobjects/Opportunity/")); request.Method = "POST"; using (var requestWriter = new StreamWriter(request.GetRequestStream())) { requestWriter.Write(json); requestWriter.Flush(); requestWriter.Close(); } var response = request.GetResponse(); }I am able to create a single opportunity using above code. But when i try to create multiple record using below "newrecord.json" file getting error.
Example request body for multiple record newrecord.json file :
[{"Name":"Opp1","CloseDate":"2015-05-02","StageName":"Stage1","Probability":"10","Amount":"1500"},{"Name":"Opp2","CloseDate":"2015-02-03","StageName":"Stage2","Probability":"5","Amount":"2000"}]
Error in .net Code : 400 bad request
Error in Workbench : errorCode: METHOD_NOT_ALLOWED
message: HTTP Method 'POST' not allowed. Allowed are HEAD,GET
The REST API you are using does not support bulk insert. To create bulk records using REST API you need to use Bulk API. Here I would explain ho to do it:
Step1:
Authorize with Salesforce: Use your authentication method to authorize yourself with Salesforce.
Step2:
Create bulk API job in Salesforce:
Request Body -
You will receive a response like this:
Step3:
Set data into CSV format for the job
Once you are done with creating the job, the next step would be setting up data that you want to insert into the created bulk job. To do that prepare data in CSV or use https://www.convertcsv.com/json-to-csv.htm (https://www.convertcsv.com/json-to-csv.htm" style="color:blue; text-decoration:underline) to convert your existing data into CSV
Request Body – Your CSV data
Step4;
Start the bulk job
Once you are done with setting up the job. The last step would be notifying Salesforce to start the job.
Request Body –
Your are done! To check your job status, use this method:
Go to https://trailhead.salesforce.com/en/content/learn/modules/api_basics/api_basics_bulk for the example.