REST API composite resources are helpful to improve application's
performance by minimizing the number of round-trips between the client and server.
what is Composite resources ?
Composite resources is an enhanced form of rest api which executes a series of rest api
requests in a single call.
It helps you to do multiple operations like read, create, update and delete salesforce data in single callout.
Note :
you can use output of one request as the input to a subsequent request response bodies and status of all these rest api
requests are together returned in a single response body.
All the series of rest apis are counted as a single call towards your API limits.This is executed in the context of the same user.
1.Series of REST API requests in a single call.
2.Multiple CRUD Operations.
3.Output of one request as the input to a subsequent request.
4.Response bodies and status in a single response body.
5.Counts as a single call towards your API limits.
6.Executed in context of the same user.
Composite Resources consists of
1.URI : /vxx.x/composite
2.Formats - JSON
3.HTTP method- GET,POST
4.Authorization : Bearer token
5.Composite Request Body
6.Composite Response Body
Composite request body :
{
"allOrNone" : true,
"collateSubrequests": true,
"compositeRequest" : [
{ Composite Subrequest},
{ Composite Subrequest},
{ Composite Subrequest}
]
}
Composite request response :
{
"compositeResponse" : [
{ Composite Subrequest Result },
{ Composite Subrequest Result },
{ Composite Subrequest Result }
]
}
Why Composite Resources
Lets understand the advantage of composite API.
1.Multiple REST API calls for single call
2.Processing speed can be made faster by collating the subrequests.
3.Improves the performance of the application
4.No additional coding required at Salesforce.
5.Single call toward API limits.
6.Synchronous responses.
7.Multiple ways in composite resources work.
8.Upsert upto five levels deep relationships.
9.Flexible on upserting related or non related records.
10.Can do a GET subrequest and the result can be input to next POST subrequest.
11.Can handle more complicated and related objects and data.
Types of Composite Resources :
1.Composite API
2.Batch
3.SObject Tree
4.SObject Collection
5.Grapths