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>>