SlideShare a Scribd company logo
1 of 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?

More Related Content

What's hot

Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software designMatthias Noback
 
Java 9/10/11 - What's new and why you should upgrade
Java 9/10/11 - What's new and why you should upgradeJava 9/10/11 - What's new and why you should upgrade
Java 9/10/11 - What's new and why you should upgradeSimone Bordet
 
The Secrets of Hexagonal Architecture
The Secrets of Hexagonal ArchitectureThe Secrets of Hexagonal Architecture
The Secrets of Hexagonal ArchitectureNicolas Carlo
 
asp.net Webconfiguration
asp.net Webconfigurationasp.net Webconfiguration
asp.net WebconfigurationMa Kik
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applicationsFabricio Epaminondas
 
Acercándonos a la Programación Funcional a través de la Arquitectura Hexag...
Acercándonos a la Programación Funcional a través de la Arquitectura Hexag...Acercándonos a la Programación Funcional a través de la Arquitectura Hexag...
Acercándonos a la Programación Funcional a través de la Arquitectura Hexag...CodelyTV
 
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud EnvironmentsTools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud EnvironmentsVMware Tanzu
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming WebStackAcademy
 
Asp.Net Core MVC with Entity Framework
Asp.Net Core MVC with Entity FrameworkAsp.Net Core MVC with Entity Framework
Asp.Net Core MVC with Entity FrameworkShravan A
 
Dynamics 365 CRM Javascript Customization
Dynamics 365 CRM Javascript CustomizationDynamics 365 CRM Javascript Customization
Dynamics 365 CRM Javascript CustomizationSanjaya Prakash Pradhan
 
Learn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database FirstLearn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database FirstJibran Rasheed Khan
 
MVC and Entity Framework
MVC and Entity FrameworkMVC and Entity Framework
MVC and Entity FrameworkJames Johnson
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectJadson Santos
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS ArchitectureEyal Vardi
 

What's hot (20)

Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software design
 
Powershell Demo Presentation
Powershell Demo PresentationPowershell Demo Presentation
Powershell Demo Presentation
 
Java 9/10/11 - What's new and why you should upgrade
Java 9/10/11 - What's new and why you should upgradeJava 9/10/11 - What's new and why you should upgrade
Java 9/10/11 - What's new and why you should upgrade
 
The Secrets of Hexagonal Architecture
The Secrets of Hexagonal ArchitectureThe Secrets of Hexagonal Architecture
The Secrets of Hexagonal Architecture
 
asp.net Webconfiguration
asp.net Webconfigurationasp.net Webconfiguration
asp.net Webconfiguration
 
Hexagonal architecture for java applications
Hexagonal architecture for java applicationsHexagonal architecture for java applications
Hexagonal architecture for java applications
 
Acercándonos a la Programación Funcional a través de la Arquitectura Hexag...
Acercándonos a la Programación Funcional a través de la Arquitectura Hexag...Acercándonos a la Programación Funcional a través de la Arquitectura Hexag...
Acercándonos a la Programación Funcional a través de la Arquitectura Hexag...
 
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud EnvironmentsTools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
 
Introduction Node.js
Introduction Node.jsIntroduction Node.js
Introduction Node.js
 
Asp.Net Core MVC with Entity Framework
Asp.Net Core MVC with Entity FrameworkAsp.Net Core MVC with Entity Framework
Asp.Net Core MVC with Entity Framework
 
Spring annotation
Spring annotationSpring annotation
Spring annotation
 
Dynamics 365 CRM Javascript Customization
Dynamics 365 CRM Javascript CustomizationDynamics 365 CRM Javascript Customization
Dynamics 365 CRM Javascript Customization
 
Learn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database FirstLearn Entity Framework in a day with Code First, Model First and Database First
Learn Entity Framework in a day with Code First, Model First and Database First
 
MSDN - ASP.NET MVC
MSDN - ASP.NET MVCMSDN - ASP.NET MVC
MSDN - ASP.NET MVC
 
MVC and Entity Framework
MVC and Entity FrameworkMVC and Entity Framework
MVC and Entity Framework
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
 
What’s New in Angular 14?
What’s New in Angular 14?What’s New in Angular 14?
What’s New in Angular 14?
 
Express node js
Express node jsExpress node js
Express node js
 

Viewers also liked

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
 

Viewers also liked (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
 

Similar to 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
 
Introduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST APIIntroduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST APIRob Windsor
 
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
 

Similar to 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
 
Introduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST APIIntroduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST 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
 

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

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

Recently uploaded

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Recently uploaded (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

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/