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

curl https://MyDomainName.my.salesforce.com/services/data/v68.0/composite/batch/ -H "Authorization: Bearer token -H "Content-Type: application/json" -d "@batch.json"

Request body batch.json file

{
"batchRequests" : [
    {
    "method" : "PATCH",
    "url" : "v68.0/sobjects/account/001D000000K0fXOIAZ",
    "richInput" : {"Name" : "NewName"}
    },{
    "method" : "GET",
    "url" : "v68.0/sobjects/account/001D000000K0fXOIAZ?fields=Name,BillingPostalCode"
    }]
} 

Response body after successfully executing the subrequests

{
   "hasErrors" : false,
   "results" : [{
      "statusCode" : 204,
      "result" : null
      },{
      "statusCode" : 200,
      "result": {
         "attributes" : {
            "type" : "Account",
            "url" : "/services/data/v68.0/sobjects/Account/001D000000K0fXOIAZ"
         },
         "Name" : "NewName",
         "BillingPostalCode" : "94105",
         "Id" : "001D000000K0fXOIAZ"
      }
   }]
}

See Also