Newer Version Available
Update a Record and Get Its Field Values in a Single Request
Use the Composite Batch resource to execute multiple requests in a single API
call.
The following example updates the name on an account and gets some of the account’s field values in a single request. The batch.json file contains the subrequest data.
- Update a record and query its name and billing postal code in a single request
-
1curl https://MyDomainName.my.salesforce.com/services/data/v63.0/composite/batch/ -H "Authorization: Bearer token -H "Content-Type: application/json" -d "@batch.json" - Request body batch.json file
-
1{ 2"batchRequests" : [ 3 { 4 "method" : "PATCH", 5 "url" : "v63.0/sobjects/account/001D000000K0fXOIAZ", 6 "richInput" : {"Name" : "NewName"} 7 },{ 8 "method" : "GET", 9 "url" : "v63.0/sobjects/account/001D000000K0fXOIAZ?fields=Name,BillingPostalCode" 10 }] 11} - Response body after successfully executing the subrequests
-
1{ 2 "hasErrors" : false, 3 "results" : [{ 4 "statusCode" : 204, 5 "result" : null 6 },{ 7 "statusCode" : 200, 8 "result": { 9 "attributes" : { 10 "type" : "Account", 11 "url" : "/services/data/v63.0/sobjects/Account/001D000000K0fXOIAZ" 12 }, 13 "Name" : "NewName", 14 "BillingPostalCode" : "94105", 15 "Id" : "001D000000K0fXOIAZ" 16 } 17 }] 18}