Tuesday, 19 May 2015

REST API | New Resources | Summer 15 | Composite Resources in Salesforce

Composite Resources
Salesforce introduces two composite resources for improving your application’s performance by minimizing the number of round trips between client and server.

Batch
vXX.X/composite/batch
The Batch resource lets you execute a sequence of independent subrequests. For example, you can update the name on an account and get the account’s field values in a single request

{
"batchRequests" : [
    {
    "method" : "PATCH",
    "url" : "v34.0/sobjects/account/001D000000K0fXOIAZ",
    "richInput" : {"Name" : "NewName"}
    },{
    "method" : "GET",
    "url" : "v34.0/sobjects/account/001D000000K0fXOIAZ"
    }]
} 
The response contains the status codes of each subresponse and the responses themselves.
{   
"hasErrors" : false,
"results" : [
    {     
    "statusCode" : 204,
    "result" : null
    },{
    "statusCode" : 200,
    "result" : { Account attributes }
    }] 
}

The Batch resource supports batching for the following resources and resource groups

Versions/
Resources by VersionvXX.X
Limits
vXX.X/limits
SObject resources
vXX.X/sobjects/
Query
vXX.X/query/?q=soql
QueryAll
vXX.X/queryAll/?q=soql
Search
vXX.X/search/?q=sosl
Connect resources
vXX.X/connect/
Chatter resources
vXX.X/chatter/
SObject Tree
vXX.X/composite/tree


NOTE:- It won't work, but that's because it will not be available until version 34 of the API.
But if you get a pre-release org, you can do the same with the updated API version

Source of Link :-
http://releasenotes.docs.salesforce.com/en-us/summer15/release-notes/rn_api_rest.htm
https://help.salesforce.com/apex/HTViewSolution?id=000214070&language=en_US
https://help.salesforce.com/apex/HTViewSolution?id=000214070&language=en_US
http://salesforce.stackexchange.com/questions/76155/rest-api-version-where-is-it-defined-what-are-the-consequences-for-updating 


<<PREVIOUS       NEXT>>





3 comments:

  1. Composite API helps in Performance Improvement at Client Side rather than at Server Side.

    ReplyDelete
  2. The current limit for number of objects is 25. Can we increase the limit of this operation? Also can we decrease the response time?

    ReplyDelete
  3. The response body doesnt contain any account attribute if there is an error. It just contains reason for error. Is there a way we can get account attribute for it?

    ReplyDelete