SlideShare ist ein Scribd-Unternehmen logo
1 von 40
SharePoint 2013 Development using 
CSOM and OData 
Kashif Imran 
Kashif_imran@hotmail.com
Agenda 
 SharePoint APIs 
 Which API to Use? 
 SharePoint CSOM 
 CSOM Architecture 
 CSOM in SharePoint 2010 VS 2013 
 .NET Client OM 
 Silverlight Client OM 
 JavaScript Client OM 
 REST/Odata 
 Questions?
SharePoint APIs 
 Server Object Model 
 Client Object Model 
 .NET Client OM 
 Silverlight (and Mobile) Client OM 
 JavaScript Client OM 
 REST/OData Endpoints 
 ASP.NET (asmx) web services 
 Only supported for backward compatibility 
 Direct Remote Procedure Calls (RPC) calls to the 
owssvr.dll 
 Only supported for backward compatibility
Which API to use? 
 Type of Application 
 Farm Solutions (w3wp.exe) 
 With great power comes great responsibility 
 Sandboxed Solutions (SPUCWorkerProcess.exe) 
 MSDN Controversy - “Developing new sandboxed solutions against 
SharePoint 2013 Preview is deprecated in favor of developing apps 
for SharePoint, but sandboxed solutions can still be installed to site 
collections on SharePoint 2013 Preview.” 
 SharePoint Apps (SharePoint-Hosted, Cloud-Hosted) 
 Custom Logic in apps is distributed down to the client or up to the 
cloud 
 Must use one of the client object models or REST/OData endpoint 
 Existing Skills 
 JavaScript, ASP.NET, REST/OData, Silverlight, PowerShell 
 Target Device
SharePoint Extension Types 
Source: MSDN
SharePoint CSOM 
 API to build remote applications 
 Contains subset of functionality that is available in Server Object Model 
 Many administrative functions are not available in CSOM 
 Underlying communications is encapsulated in the runtime 
 CSOM Implementations 
 .NET Client OM 
 Silverlight Client OM 
 JavaScript Client OM 
 Type names are similar to Server Object Model but do not have prefix SP as type names in Server OM 
Server OM Managed/Silverlight 
Implementation 
JavaScript 
Implementation 
SPContext ClientContext SP.ClientContext 
SPSite Site SP.Site 
SPWeb Web SP.Web 
SPList List SP.List 
SPListItem ListItem SP.ListItem 
SPField Field SP.Field
SharePoint CSOM
CSOM Updates in SharePoint 2013 
 client.svc has been extended to support direct RESTful calls 
 OData complaint implementation and support of HTTP GET, 
PUT, POST, MERGE and DELETE 
 New APIs for Server functionality 
 Business Data 
 Search 
 Publishing 
 User Profiles 
 Taxonomy 
 Feeds 
 Sharing 
 Workflow 
 E-Discovery 
 IRM 
 Analytics
CSOM in SharePoint 2010 
 Direct access to client.svc is not supported 
 ListData.svc for REST calls and available in SP2013 
only for backward compatibility
CSOM Architecture
Authentication 
 ClientContext.AuthenticationMode 
 Anonymous 
 Default 
 FormsAuthentication 
 ClientContext.Credentials 
 Windows credentials 
 ClientContext.FormsAuthenticationLoginInfo 
 Windows credentials are passed by default in .NET 
Managed Object Model
.NET Client OM 
 Queries are sent to the SharePoint server in batches 
 Microsoft.SharePoint.Client.dll 
 Microsoft.SharePoint.Client.Runtime.dll 
 Root15ISAPI 
 ClientContext 
 Load 
 Populates objects in place 
 LoadQuery 
 Returns results for query 
 ExecuteQuery or ExecuteQueryAsync on ClientContext 
 Collection and even some non collection properties are not loaded 
by default
.NET Client OM - Load
.NET Client OM - LoadQuery
Querying List Data in CSOM vs SOM 
 CSOM querying of list is different from SOM 
 There is no GetDataTable in CSOM 
 web.Lists.GetByTitle(“Orders”) instead of 
web.Lists[“Orders”] 
 list.GetItem(query) instead of list.Items 
 item[“Title”] instead of item.Title
Demo - .NET Client OM 
Demo
.NET CSOM Rules and Best Practices 
 ClientContext.ExecuteQuery must be called before 
accessing any value properties 
ClientContext context = new ClientContext("http://SiteUrl"); 
Web web = context.Web; 
label1.Text = web.Title; 
---------------------------------------------------------- 
context.Load(web, w => w.Title); 
context.ExecuteQuery();
.NET CSOM Rules and Best Practices 
 Do not use value objects returned from methods or properties in the 
same query 
ClientContext context = new ClientContext("http://SiteUrl"); 
Web web = context.Web; 
ListCreationInformation creationInfo = new ListCreationInformation(); 
creationInfo.Description = web.Title; 
creationInfo.Title = web.Title; 
List newList = web.Lists.Add(creationInfo); 
---------------------------------------------------------- 
Web web = context.Web; 
context.Load(web, w => w.Title); 
context.ExecuteQuery(); 
ListCreationInformation creationInfo = new ListCreationInformation(); 
… 
context.ExecuteQuery();
.NET CSOM Rules and Best Practices 
 Client objects can be used in another method call in 
the same query 
ClientContext context = new ClientContext("http://SiteUrl"); 
Web web = context.Web; 
SP.List list = web.Lists.GetByTitle("Announcements");
.NET CSOM Rules and Best Practices 
 To improve performance group data retrieval on the same 
object together 
static void Method1() 
{ 
ClientContext context = new ClientContext("http://SiteUrl"); 
Web web = context.Web; 
SP.List list = web.Lists.GetByTitle("Announcements"); 
context.Load(web, w => w.Title, w => w.Description); 
context.Load(list, l => l.Description); 
context.ExecuteQuery(); 
} 
static void Method2() 
{ 
ClientContext context = new ClientContext("http://SiteUrl"); 
Web web = context.Web; 
SP.List list = web.Lists.GetByTitle("Announcements"); 
context.Load(web, w => w.Title); 
context.Load(list, l => l.Description); 
context.Load(web, w => w.Description); 
context.ExecuteQuery(); 
}
.NET CSOM Rules and Best Practices 
 Specify which properties of objects you want to return 
ClientContext context = new ClientContext("http://SiteUrl"); 
Web web = context.Web; 
context.Load(web); 
context.ExecuteQuery(); 
Console.WriteLine(web.Title); 
Console.WriteLine(web.HasUniqueRoleAssignments); 
---------------------------------------------------------- 
context.Load(web); 
context.Load(web, w => w.Title, w => 
w.HasUniqueRoleAssignments); 
context.ExecuteQuery();
Silverlight Client OM 
 All batches of commands are sent to the server 
asynchronously 
 Microsoft.SharePoint.Client.Silverlight 
 Microsoft.SharePoint.Client.Silverlight.Runtime 
 Root15TEMPLATELAYOUTSClientBin 
 Mobile Client OM (Special version of Silverlight 
Client OM) for Windows Phone devices
JavaScript Client OM 
 Same functionality as .NET Client OM 
 All batches of commands are sent to the server 
asynchronously 
 Data is returned in JSON 
 Can access data across domains but only within the 
same parent site collection 
 Root15TemplateLayouts 
 SP.js, SP.Core.js and SP.Runtime.js
Demo - JavaScript Client OM 
Demo
REST 
 REST VS SOAP 
 Lightweight and easier to implement for various 
types of potential clients 
 Various open source JavaScript libraries that support 
REST based programming 
 Facebook, LinkedIn, Twitter all has REST APIs 
 Results are returned as JSON VS ATOM 
 Results can be cached by proxy servers 
 SOAP: Same URL, request is in header 
 REST: Separate URL for different queries or 
operations
OData (Open Data Protocol) 
 Web protocol for querying and update data 
 Build upon web technologies, HTTP, AtomPub and 
JSON 
 Data is served up as XML or JSON in Atom Feed 
 Microsoft, SAP AG, IBM, Citrix, Progress Software 
and WSO2 
 OData services: Netflix, Azure 
 OData clients: Excel 2010/2013
OData Terms and Concepts 
 Built on Entity Data Model 
 Collections contain Entries like Tables contain Rows 
 Collections can be associated like Tables can be related 
 Entry has properties like Table Row has columns 
 Collections always have keys like Tables may have keys 
 Browse to service root of OData service usually returns 
all available Collections 
EDM OData 
Entity Set Collection 
Entity Type Entry 
Property of an Entity Type Property of Entry 
Navigation Property Link
OData URIs 
 Service root URI 
 Resource path 
 Query string options 
Source: odata.org
Northwind OData Queries 
 Available Collections 
 http://services.odata.org/Northwind/Northwind.svc/ 
 Metadata: 
 http://services.odata.org/Northwind/Northwind.svc/$metadata 
 Query Entity Set (Collection) 
 http://services.odata.org/Northwind/Northwind.svc/Customers 
 Customer With Single Entry 
 http://services.odata.org/Northwind/Northwind.svc/Customers('LETSS') 
 Get One Property: 
 http://services.odata.org/Northwind/Northwind.svc/Customers('LETSS')/Address 
 Value of a Property: 
 http://services.odata.org/Northwind/Northwind.svc/Customers('LETSS')/Address/$v 
alue 
 Collection of related Links without actual entries: 
 http://services.odata.org/Northwind/Northwind.svc/Customers('LETSS')/$links/Orde 
rs 
 Related Entries: 
 http://services.odata.org/Northwind/Northwind.svc/Customers('LETSS')/Orders(106 
43)/Order_Details
Query Language 
 Options: $filter, $sort, $orderby, $top, $expand, $skip, 
$take, $metadata… 
 Operations: eq, ne, gt, ge, lt, le, and, or, not, mod, add, 
sub 
 Functions: startswith, substring, replace, tolower, trim, 
round, ceiling, day, month, year, typeof,… 
 Top 3 Customer from USA Order By ContactName 
 http://services.odata.org/Northwind/Northwind.svc/Customers? 
$filter=Country eq 'USA'&$orderby=ContactName&$top=3 
 Return related Entries Inline 
 http://services.odata.org/Northwind/Northwind.svc/Customers(' 
LETSS')/$links/Orders 
 Get Data in JSON Format 
 http://services.odata.org/Northwind/Northwind.svc/Customers(' 
LETSS')?$expand=Orders&$format=JSON
CRUD Operation and HTTP Verbs 
 Standardize CRUD operations using HTTP verbs 
such as GET, PUT, POST and MERGE 
 Methods are mapped into Navigator operations via 
GET (list.getByTitle) 
CRUD Operation HTTP Verb 
Read GET 
Create POST 
Update PUT or MERGE 
Delete DELETE
SharePoint REST URLs 
 _api => _vti_bin/client.svc 
 _api/web/lists 
 _api/web/lists/lists(guid) 
 _api/web/lists/getByTitle(‘Announcements’) 
 _api/web/lists/getbytitle(‘Announcements’)/items(2)/F 
ieldValuesAsHtml/$select=Title,Author 
 _api/web/getAvailableWebTemplates(lcid=1033) 
 _api/web/?$select=title,id 
 _api/web/lists/getByTitle(‘mylist’)?$select=title,firstna 
me 
 _api/web/lists/getByTitle(‘customers’)?$select=title,fir 
stname&startswith(Title, ‘p’)
Demo - OData Queries in Browser 
Demo
ATOMPub vs JSON 
 ATOMPub: The Atom Publishing Protocol 
 Application level protocol for publishing and editing web 
resources. 
 Based on HTTP transfer of Atom-formatted representations. 
 ACCEPT = application/atom+xml 
 XML Parsing on client side (Easy in Managed Code) 
 JSON 
 Lightweight data-interchange format 
 Easy for humans to read and write. 
 Easy for machines to parse and generate 
 ACCEPT = applicatoin/json;odata=verbose 
 Client libraries like datajs 
 XML is default for SharePoint REST calls
Demo – REST calls using Managed Code 
Demo
Demo – REST calls using JavaScript 
Demo
REST/OData VS CSOM 
Feature .NET Or 
Silverlight 
Client OM 
JavaScript 
Client OM 
REST/OData 
OOP Yes Yes No 
Batch Processing Yes Yes No 
LINQ Yes No No 
Leveraging jQuery, 
Knockout and other open 
source libraries 
No Yes Yes 
Familiarity to experienced 
REST/OData developers 
No No Yes
Updates and the Form Digest 
 Form Digest can be acquired through 
http://site/_vti_bin/sites.asmx 
 Special value created to protect again replay attack 
 SharePoint adds this control through master page 
 Web service clients need to acquire Form Digest 
manually
References 
 Choose the right API set in SharePoint 2013 
 How to: Complete basic operations using SharePoint 2013 
client library code 
 How to: Complete basic operations using JavaScript library 
code in SharePoint 2013 
 How to: Access SharePoint 2013 data from remote apps using 
the cross-domain library 
 Programming using the SharePoint 2013 REST service 
 How to: Complete basic operations using SharePoint 2013 
REST endpoints 
 Host webs, app webs, and SharePoint components in 
SharePoint 2013 
 Build mobile apps in SharePoint 2013 
 http://www.odata.org/
Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

Overview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB APIOverview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB APIPankaj Bajaj
 
Front end architecture
Front end architectureFront end architecture
Front end architectureRemus Langu
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6Rob Eisenberg
 
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...Simplilearn
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework OverviewDoncho Minkov
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring FrameworkASG
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introductionRasheed Waraich
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8Simon Ritter
 
Understanding and programming the SharePoint REST API
Understanding and programming the SharePoint REST APIUnderstanding and programming the SharePoint REST API
Understanding and programming the SharePoint REST APIChris Beckett
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring FrameworkHùng Nguyễn Huy
 
Writing and using Hamcrest Matchers
Writing and using Hamcrest MatchersWriting and using Hamcrest Matchers
Writing and using Hamcrest MatchersShai Yallin
 
Microsoft dot net framework
Microsoft dot net frameworkMicrosoft dot net framework
Microsoft dot net frameworkAshish Verma
 
High-Performance Hibernate Devoxx France 2016
High-Performance Hibernate Devoxx France 2016High-Performance Hibernate Devoxx France 2016
High-Performance Hibernate Devoxx France 2016Vlad Mihalcea
 
Introduction to Ionic framework
Introduction to Ionic frameworkIntroduction to Ionic framework
Introduction to Ionic frameworkShyjal Raazi
 

Was ist angesagt? (20)

Overview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB APIOverview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB API
 
Javascript
JavascriptJavascript
Javascript
 
Front end architecture
Front end architectureFront end architecture
Front end architecture
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
 
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
 
Asp.net
 Asp.net Asp.net
Asp.net
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework Overview
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
55 New Features in Java SE 8
55 New Features in Java SE 855 New Features in Java SE 8
55 New Features in Java SE 8
 
Understanding and programming the SharePoint REST API
Understanding and programming the SharePoint REST APIUnderstanding and programming the SharePoint REST API
Understanding and programming the SharePoint REST API
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Rest api with node js and express
Rest api with node js and expressRest api with node js and express
Rest api with node js and express
 
Writing and using Hamcrest Matchers
Writing and using Hamcrest MatchersWriting and using Hamcrest Matchers
Writing and using Hamcrest Matchers
 
Microsoft dot net framework
Microsoft dot net frameworkMicrosoft dot net framework
Microsoft dot net framework
 
High-Performance Hibernate Devoxx France 2016
High-Performance Hibernate Devoxx France 2016High-Performance Hibernate Devoxx France 2016
High-Performance Hibernate Devoxx France 2016
 
.Net Core
.Net Core.Net Core
.Net Core
 
Dot Net Core
Dot Net CoreDot Net Core
Dot Net Core
 
Introduction to Ionic framework
Introduction to Ionic frameworkIntroduction to Ionic framework
Introduction to Ionic framework
 

Andere mochten auch

Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010Rob Windsor
 
Biwug 25092012 sp2013_itpro_hans_jaspers
Biwug 25092012 sp2013_itpro_hans_jaspersBiwug 25092012 sp2013_itpro_hans_jaspers
Biwug 25092012 sp2013_itpro_hans_jaspersBIWUG
 
LINQ to SharePoint
LINQ to SharePointLINQ to SharePoint
LINQ to SharePointAndré Vala
 
CSOM (Client Side Object Model). Explained @ SharePoint Saturday Houston
CSOM (Client Side Object Model). Explained @ SharePoint Saturday HoustonCSOM (Client Side Object Model). Explained @ SharePoint Saturday Houston
CSOM (Client Side Object Model). Explained @ SharePoint Saturday HoustonKunaal Kapoor
 
Social features in SharePoint 2013
Social features in SharePoint 2013Social features in SharePoint 2013
Social features in SharePoint 2013Michael Doyle
 
The SharePoint & jQuery Guide
The SharePoint & jQuery GuideThe SharePoint & jQuery Guide
The SharePoint & jQuery GuideMark Rackley
 
Karine bosch andy-van_steenbergen-caml-spsbe12
Karine bosch andy-van_steenbergen-caml-spsbe12Karine bosch andy-van_steenbergen-caml-spsbe12
Karine bosch andy-van_steenbergen-caml-spsbe12BIWUG
 
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechConDeep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechConSPTechCon
 

Andere mochten auch (8)

Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010
 
Biwug 25092012 sp2013_itpro_hans_jaspers
Biwug 25092012 sp2013_itpro_hans_jaspersBiwug 25092012 sp2013_itpro_hans_jaspers
Biwug 25092012 sp2013_itpro_hans_jaspers
 
LINQ to SharePoint
LINQ to SharePointLINQ to SharePoint
LINQ to SharePoint
 
CSOM (Client Side Object Model). Explained @ SharePoint Saturday Houston
CSOM (Client Side Object Model). Explained @ SharePoint Saturday HoustonCSOM (Client Side Object Model). Explained @ SharePoint Saturday Houston
CSOM (Client Side Object Model). Explained @ SharePoint Saturday Houston
 
Social features in SharePoint 2013
Social features in SharePoint 2013Social features in SharePoint 2013
Social features in SharePoint 2013
 
The SharePoint & jQuery Guide
The SharePoint & jQuery GuideThe SharePoint & jQuery Guide
The SharePoint & jQuery Guide
 
Karine bosch andy-van_steenbergen-caml-spsbe12
Karine bosch andy-van_steenbergen-caml-spsbe12Karine bosch andy-van_steenbergen-caml-spsbe12
Karine bosch andy-van_steenbergen-caml-spsbe12
 
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechConDeep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
Deep Dive into the Content Query Web Part by Christina Wheeler - SPTechCon
 

Ähnlich wie SharePoint Client Object Model (CSOM)

Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...SharePoint Saturday NY
 
Develop iOS and Android apps with SharePoint/Office 365
Develop iOS and Android apps with SharePoint/Office 365Develop iOS and Android apps with SharePoint/Office 365
Develop iOS and Android apps with SharePoint/Office 365Kashif Imran
 
4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio Angulo
4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio Angulo4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio Angulo
4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio AnguloLuis Du Solier
 
Rest API and Client OM for Developer
Rest API and Client OM for DeveloperRest API and Client OM for Developer
Rest API and Client OM for DeveloperInnoTech
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NETPeter Gfader
 
Introduction to the Client OM in SharePoint 2010
Introduction to the Client OM in SharePoint 2010Introduction to the Client OM in SharePoint 2010
Introduction to the Client OM in SharePoint 2010Ben Robb
 
Apps 101 - Moving to the SharePoint 2013 App Model - Presented 7/27/13 at Sha...
Apps 101 - Moving to the SharePoint 2013 App Model - Presented 7/27/13 at Sha...Apps 101 - Moving to the SharePoint 2013 App Model - Presented 7/27/13 at Sha...
Apps 101 - Moving to the SharePoint 2013 App Model - Presented 7/27/13 at Sha...BlueMetalInc
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
Asp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentAsp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentChui-Wen Chiu
 
Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Servicesukdpe
 
ADO.NET Data Services
ADO.NET Data ServicesADO.NET Data Services
ADO.NET Data Servicesukdpe
 
ASP.NET Request Processing Internals
ASP.NET Request Processing InternalsASP.NET Request Processing Internals
ASP.NET Request Processing InternalsAbhijit Jana
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods pptkamal kotecha
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showSubhas Malik
 

Ähnlich wie SharePoint Client Object Model (CSOM) (20)

Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
 
Develop iOS and Android apps with SharePoint/Office 365
Develop iOS and Android apps with SharePoint/Office 365Develop iOS and Android apps with SharePoint/Office 365
Develop iOS and Android apps with SharePoint/Office 365
 
4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio Angulo
4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio Angulo4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio Angulo
4 - Silverlight y SharePoint, por Rodrigo Diaz y Mauricio Angulo
 
Rest API and Client OM for Developer
Rest API and Client OM for DeveloperRest API and Client OM for Developer
Rest API and Client OM for Developer
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
Introduction to the Client OM in SharePoint 2010
Introduction to the Client OM in SharePoint 2010Introduction to the Client OM in SharePoint 2010
Introduction to the Client OM in SharePoint 2010
 
Day7
Day7Day7
Day7
 
06 web api
06 web api06 web api
06 web api
 
Developing With Data Technologies
Developing With Data TechnologiesDeveloping With Data Technologies
Developing With Data Technologies
 
Walther Ajax4
Walther Ajax4Walther Ajax4
Walther Ajax4
 
Apps 101 - Moving to the SharePoint 2013 App Model - Presented 7/27/13 at Sha...
Apps 101 - Moving to the SharePoint 2013 App Model - Presented 7/27/13 at Sha...Apps 101 - Moving to the SharePoint 2013 App Model - Presented 7/27/13 at Sha...
Apps 101 - Moving to the SharePoint 2013 App Model - Presented 7/27/13 at Sha...
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Web api
Web apiWeb api
Web api
 
PPT
PPTPPT
PPT
 
Asp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentAsp.Net Ajax Component Development
Asp.Net Ajax Component Development
 
Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Services
 
ADO.NET Data Services
ADO.NET Data ServicesADO.NET Data Services
ADO.NET Data Services
 
ASP.NET Request Processing Internals
ASP.NET Request Processing InternalsASP.NET Request Processing Internals
ASP.NET Request Processing Internals
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
 

Mehr von Kashif Imran

Securing SharePoint Apps with OAuth
Securing SharePoint Apps with OAuthSecuring SharePoint Apps with OAuth
Securing SharePoint Apps with OAuthKashif Imran
 
SharePoint, ADFS and Claims Auth
SharePoint, ADFS and Claims AuthSharePoint, ADFS and Claims Auth
SharePoint, ADFS and Claims AuthKashif Imran
 
Developing Apps for SharePoint Store
Developing Apps for SharePoint StoreDeveloping Apps for SharePoint Store
Developing Apps for SharePoint StoreKashif Imran
 
SharePoint 2013 Branding
SharePoint 2013 BrandingSharePoint 2013 Branding
SharePoint 2013 BrandingKashif Imran
 
Enterprise Content Management (ECM) in the Cloud
Enterprise Content Management (ECM) in the CloudEnterprise Content Management (ECM) in the Cloud
Enterprise Content Management (ECM) in the CloudKashif Imran
 
Microsoft Azure WebJobs
Microsoft Azure WebJobsMicrosoft Azure WebJobs
Microsoft Azure WebJobsKashif Imran
 
Microsoft Azure - Introduction
Microsoft Azure - IntroductionMicrosoft Azure - Introduction
Microsoft Azure - IntroductionKashif Imran
 

Mehr von Kashif Imran (8)

Securing SharePoint Apps with OAuth
Securing SharePoint Apps with OAuthSecuring SharePoint Apps with OAuth
Securing SharePoint Apps with OAuth
 
SharePoint, ADFS and Claims Auth
SharePoint, ADFS and Claims AuthSharePoint, ADFS and Claims Auth
SharePoint, ADFS and Claims Auth
 
Developing Apps for SharePoint Store
Developing Apps for SharePoint StoreDeveloping Apps for SharePoint Store
Developing Apps for SharePoint Store
 
SharePoint 2013 Branding
SharePoint 2013 BrandingSharePoint 2013 Branding
SharePoint 2013 Branding
 
Enterprise Content Management (ECM) in the Cloud
Enterprise Content Management (ECM) in the CloudEnterprise Content Management (ECM) in the Cloud
Enterprise Content Management (ECM) in the Cloud
 
Microsoft Azure WebJobs
Microsoft Azure WebJobsMicrosoft Azure WebJobs
Microsoft Azure WebJobs
 
Azure Websites
Azure WebsitesAzure Websites
Azure Websites
 
Microsoft Azure - Introduction
Microsoft Azure - IntroductionMicrosoft Azure - Introduction
Microsoft Azure - Introduction
 

Kürzlich hochgeladen

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 

Kürzlich hochgeladen (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

SharePoint Client Object Model (CSOM)

  • 1. SharePoint 2013 Development using CSOM and OData Kashif Imran Kashif_imran@hotmail.com
  • 2. Agenda  SharePoint APIs  Which API to Use?  SharePoint CSOM  CSOM Architecture  CSOM in SharePoint 2010 VS 2013  .NET Client OM  Silverlight Client OM  JavaScript Client OM  REST/Odata  Questions?
  • 3. SharePoint APIs  Server Object Model  Client Object Model  .NET Client OM  Silverlight (and Mobile) Client OM  JavaScript Client OM  REST/OData Endpoints  ASP.NET (asmx) web services  Only supported for backward compatibility  Direct Remote Procedure Calls (RPC) calls to the owssvr.dll  Only supported for backward compatibility
  • 4. Which API to use?  Type of Application  Farm Solutions (w3wp.exe)  With great power comes great responsibility  Sandboxed Solutions (SPUCWorkerProcess.exe)  MSDN Controversy - “Developing new sandboxed solutions against SharePoint 2013 Preview is deprecated in favor of developing apps for SharePoint, but sandboxed solutions can still be installed to site collections on SharePoint 2013 Preview.”  SharePoint Apps (SharePoint-Hosted, Cloud-Hosted)  Custom Logic in apps is distributed down to the client or up to the cloud  Must use one of the client object models or REST/OData endpoint  Existing Skills  JavaScript, ASP.NET, REST/OData, Silverlight, PowerShell  Target Device
  • 6. SharePoint CSOM  API to build remote applications  Contains subset of functionality that is available in Server Object Model  Many administrative functions are not available in CSOM  Underlying communications is encapsulated in the runtime  CSOM Implementations  .NET Client OM  Silverlight Client OM  JavaScript Client OM  Type names are similar to Server Object Model but do not have prefix SP as type names in Server OM Server OM Managed/Silverlight Implementation JavaScript Implementation SPContext ClientContext SP.ClientContext SPSite Site SP.Site SPWeb Web SP.Web SPList List SP.List SPListItem ListItem SP.ListItem SPField Field SP.Field
  • 8. CSOM Updates in SharePoint 2013  client.svc has been extended to support direct RESTful calls  OData complaint implementation and support of HTTP GET, PUT, POST, MERGE and DELETE  New APIs for Server functionality  Business Data  Search  Publishing  User Profiles  Taxonomy  Feeds  Sharing  Workflow  E-Discovery  IRM  Analytics
  • 9. CSOM in SharePoint 2010  Direct access to client.svc is not supported  ListData.svc for REST calls and available in SP2013 only for backward compatibility
  • 11. Authentication  ClientContext.AuthenticationMode  Anonymous  Default  FormsAuthentication  ClientContext.Credentials  Windows credentials  ClientContext.FormsAuthenticationLoginInfo  Windows credentials are passed by default in .NET Managed Object Model
  • 12. .NET Client OM  Queries are sent to the SharePoint server in batches  Microsoft.SharePoint.Client.dll  Microsoft.SharePoint.Client.Runtime.dll  Root15ISAPI  ClientContext  Load  Populates objects in place  LoadQuery  Returns results for query  ExecuteQuery or ExecuteQueryAsync on ClientContext  Collection and even some non collection properties are not loaded by default
  • 13. .NET Client OM - Load
  • 14. .NET Client OM - LoadQuery
  • 15. Querying List Data in CSOM vs SOM  CSOM querying of list is different from SOM  There is no GetDataTable in CSOM  web.Lists.GetByTitle(“Orders”) instead of web.Lists[“Orders”]  list.GetItem(query) instead of list.Items  item[“Title”] instead of item.Title
  • 16. Demo - .NET Client OM Demo
  • 17. .NET CSOM Rules and Best Practices  ClientContext.ExecuteQuery must be called before accessing any value properties ClientContext context = new ClientContext("http://SiteUrl"); Web web = context.Web; label1.Text = web.Title; ---------------------------------------------------------- context.Load(web, w => w.Title); context.ExecuteQuery();
  • 18. .NET CSOM Rules and Best Practices  Do not use value objects returned from methods or properties in the same query ClientContext context = new ClientContext("http://SiteUrl"); Web web = context.Web; ListCreationInformation creationInfo = new ListCreationInformation(); creationInfo.Description = web.Title; creationInfo.Title = web.Title; List newList = web.Lists.Add(creationInfo); ---------------------------------------------------------- Web web = context.Web; context.Load(web, w => w.Title); context.ExecuteQuery(); ListCreationInformation creationInfo = new ListCreationInformation(); … context.ExecuteQuery();
  • 19. .NET CSOM Rules and Best Practices  Client objects can be used in another method call in the same query ClientContext context = new ClientContext("http://SiteUrl"); Web web = context.Web; SP.List list = web.Lists.GetByTitle("Announcements");
  • 20. .NET CSOM Rules and Best Practices  To improve performance group data retrieval on the same object together static void Method1() { ClientContext context = new ClientContext("http://SiteUrl"); Web web = context.Web; SP.List list = web.Lists.GetByTitle("Announcements"); context.Load(web, w => w.Title, w => w.Description); context.Load(list, l => l.Description); context.ExecuteQuery(); } static void Method2() { ClientContext context = new ClientContext("http://SiteUrl"); Web web = context.Web; SP.List list = web.Lists.GetByTitle("Announcements"); context.Load(web, w => w.Title); context.Load(list, l => l.Description); context.Load(web, w => w.Description); context.ExecuteQuery(); }
  • 21. .NET CSOM Rules and Best Practices  Specify which properties of objects you want to return ClientContext context = new ClientContext("http://SiteUrl"); Web web = context.Web; context.Load(web); context.ExecuteQuery(); Console.WriteLine(web.Title); Console.WriteLine(web.HasUniqueRoleAssignments); ---------------------------------------------------------- context.Load(web); context.Load(web, w => w.Title, w => w.HasUniqueRoleAssignments); context.ExecuteQuery();
  • 22. Silverlight Client OM  All batches of commands are sent to the server asynchronously  Microsoft.SharePoint.Client.Silverlight  Microsoft.SharePoint.Client.Silverlight.Runtime  Root15TEMPLATELAYOUTSClientBin  Mobile Client OM (Special version of Silverlight Client OM) for Windows Phone devices
  • 23. JavaScript Client OM  Same functionality as .NET Client OM  All batches of commands are sent to the server asynchronously  Data is returned in JSON  Can access data across domains but only within the same parent site collection  Root15TemplateLayouts  SP.js, SP.Core.js and SP.Runtime.js
  • 24. Demo - JavaScript Client OM Demo
  • 25. REST  REST VS SOAP  Lightweight and easier to implement for various types of potential clients  Various open source JavaScript libraries that support REST based programming  Facebook, LinkedIn, Twitter all has REST APIs  Results are returned as JSON VS ATOM  Results can be cached by proxy servers  SOAP: Same URL, request is in header  REST: Separate URL for different queries or operations
  • 26. OData (Open Data Protocol)  Web protocol for querying and update data  Build upon web technologies, HTTP, AtomPub and JSON  Data is served up as XML or JSON in Atom Feed  Microsoft, SAP AG, IBM, Citrix, Progress Software and WSO2  OData services: Netflix, Azure  OData clients: Excel 2010/2013
  • 27. OData Terms and Concepts  Built on Entity Data Model  Collections contain Entries like Tables contain Rows  Collections can be associated like Tables can be related  Entry has properties like Table Row has columns  Collections always have keys like Tables may have keys  Browse to service root of OData service usually returns all available Collections EDM OData Entity Set Collection Entity Type Entry Property of an Entity Type Property of Entry Navigation Property Link
  • 28. OData URIs  Service root URI  Resource path  Query string options Source: odata.org
  • 29. Northwind OData Queries  Available Collections  http://services.odata.org/Northwind/Northwind.svc/  Metadata:  http://services.odata.org/Northwind/Northwind.svc/$metadata  Query Entity Set (Collection)  http://services.odata.org/Northwind/Northwind.svc/Customers  Customer With Single Entry  http://services.odata.org/Northwind/Northwind.svc/Customers('LETSS')  Get One Property:  http://services.odata.org/Northwind/Northwind.svc/Customers('LETSS')/Address  Value of a Property:  http://services.odata.org/Northwind/Northwind.svc/Customers('LETSS')/Address/$v alue  Collection of related Links without actual entries:  http://services.odata.org/Northwind/Northwind.svc/Customers('LETSS')/$links/Orde rs  Related Entries:  http://services.odata.org/Northwind/Northwind.svc/Customers('LETSS')/Orders(106 43)/Order_Details
  • 30. Query Language  Options: $filter, $sort, $orderby, $top, $expand, $skip, $take, $metadata…  Operations: eq, ne, gt, ge, lt, le, and, or, not, mod, add, sub  Functions: startswith, substring, replace, tolower, trim, round, ceiling, day, month, year, typeof,…  Top 3 Customer from USA Order By ContactName  http://services.odata.org/Northwind/Northwind.svc/Customers? $filter=Country eq 'USA'&$orderby=ContactName&$top=3  Return related Entries Inline  http://services.odata.org/Northwind/Northwind.svc/Customers(' LETSS')/$links/Orders  Get Data in JSON Format  http://services.odata.org/Northwind/Northwind.svc/Customers(' LETSS')?$expand=Orders&$format=JSON
  • 31. CRUD Operation and HTTP Verbs  Standardize CRUD operations using HTTP verbs such as GET, PUT, POST and MERGE  Methods are mapped into Navigator operations via GET (list.getByTitle) CRUD Operation HTTP Verb Read GET Create POST Update PUT or MERGE Delete DELETE
  • 32. SharePoint REST URLs  _api => _vti_bin/client.svc  _api/web/lists  _api/web/lists/lists(guid)  _api/web/lists/getByTitle(‘Announcements’)  _api/web/lists/getbytitle(‘Announcements’)/items(2)/F ieldValuesAsHtml/$select=Title,Author  _api/web/getAvailableWebTemplates(lcid=1033)  _api/web/?$select=title,id  _api/web/lists/getByTitle(‘mylist’)?$select=title,firstna me  _api/web/lists/getByTitle(‘customers’)?$select=title,fir stname&startswith(Title, ‘p’)
  • 33. Demo - OData Queries in Browser Demo
  • 34. ATOMPub vs JSON  ATOMPub: The Atom Publishing Protocol  Application level protocol for publishing and editing web resources.  Based on HTTP transfer of Atom-formatted representations.  ACCEPT = application/atom+xml  XML Parsing on client side (Easy in Managed Code)  JSON  Lightweight data-interchange format  Easy for humans to read and write.  Easy for machines to parse and generate  ACCEPT = applicatoin/json;odata=verbose  Client libraries like datajs  XML is default for SharePoint REST calls
  • 35. Demo – REST calls using Managed Code Demo
  • 36. Demo – REST calls using JavaScript Demo
  • 37. REST/OData VS CSOM Feature .NET Or Silverlight Client OM JavaScript Client OM REST/OData OOP Yes Yes No Batch Processing Yes Yes No LINQ Yes No No Leveraging jQuery, Knockout and other open source libraries No Yes Yes Familiarity to experienced REST/OData developers No No Yes
  • 38. Updates and the Form Digest  Form Digest can be acquired through http://site/_vti_bin/sites.asmx  Special value created to protect again replay attack  SharePoint adds this control through master page  Web service clients need to acquire Form Digest manually
  • 39. References  Choose the right API set in SharePoint 2013  How to: Complete basic operations using SharePoint 2013 client library code  How to: Complete basic operations using JavaScript library code in SharePoint 2013  How to: Access SharePoint 2013 data from remote apps using the cross-domain library  Programming using the SharePoint 2013 REST service  How to: Complete basic operations using SharePoint 2013 REST endpoints  Host webs, app webs, and SharePoint components in SharePoint 2013  Build mobile apps in SharePoint 2013  http://www.odata.org/