REST
REST is Representational State Transfer. It is an architectural style and uses HTTP protocol. SharePoint 2013 onwards REST API is supported.
For filtering data, REST supports OData protocol.
One of the example of REST URL is given below:
http://server/_api/web/lists
JSOM
JSOM (JavaScript Object Model) is a CSOM (Client Side Object Model) interacting with SharePoint. This programming way is available from SharePoint 2010 onwards. JSOM programming requires the following:
REST is Representational State Transfer. It is an architectural style and uses HTTP protocol. SharePoint 2013 onwards REST API is supported.
For filtering data, REST supports OData protocol.
One of the example of REST URL is given below:
http://server/_api/web/lists
JSOM
JSOM (JavaScript Object Model) is a CSOM (Client Side Object Model) interacting with SharePoint. This programming way is available from SharePoint 2010 onwards. JSOM programming requires the following:
- Deeper understanding of the SharePoint CSOM API.
- Reference to JSOM JavaScript files.
- CAML query used for filtering.
Here's an example code for JSOM:
.
var listTitle = "Contacts";
.
using(var context = new ClientContext(“http://url”))
.
{
.
var list = context.Web.Lists.GetByTitle(listTitle);
.
context.Load(list);
.
context.ExecuteQuery();
.
}
REST Advantages
The following are the advantages of going with REST:
The following are the advantages of going with REST:
- REST web requests are easier to work with that we can use Browser to test them.
- No overheads of WSDL creation Or Detailed SharePoint knowledge required.
- No overheads of tying up with Service Reference.
- Direct calls for fetch, insert, update, delete, and find operations.
- Better Interoperability supporting different clients on
different platforms, programming models.
In this way REST is more preferred among SharePoint Programmers.
JSOM Advantages
The following are the advantages of JSOM over REST which I would prefer to use only in particular scenarios.
The following are the advantages of JSOM over REST which I would prefer to use only in particular scenarios.
JSOM supports Batching
Batching is the technique of tying multiple queries and sending to server. In this way, the roundtrip can be reduced to one.
Scenario: You have a Web Page where 10 list items need to be loaded. In the case of REST, this will require 10 roundtrips to the server, right?
But if you are using JSOM, you can wrap all the queries into one roundtrip. Invoke the Load() method multiple times as shown below.
Batching is the technique of tying multiple queries and sending to server. In this way, the roundtrip can be reduced to one.
Scenario: You have a Web Page where 10 list items need to be loaded. In the case of REST, this will require 10 roundtrips to the server, right?
But if you are using JSOM, you can wrap all the queries into one roundtrip. Invoke the Load() method multiple times as shown below.
- context.Load(list1);
- context.Load(list2);
- context.Load(list10);
Then we
can call the ExecuteQuery() method which will actually send the query to
the server. This is the advantage of Batching in JSOM.
Note: Chattier is another term that means the opposite of Batching. Chattier means it requires chat like request-response between client & server. So REST is chattier & JSOM not.
Note: Chattier is another term that means the opposite of Batching. Chattier means it requires chat like request-response between client & server. So REST is chattier & JSOM not.
No comments:
Post a Comment