_api: : The evolution of
the Client Object Model
and REST API for
SharePoint 2013
Rob Windsor
rwindsor@portalsolutions.net...
About Me
• Senior SharePoint Architect with Portal Solutions
• Technical Contributor to the Pluralsight On-Demand Library
...
Client(-Side) Object Model (CSOM)
• API used when building remote applications
 Introduced in SharePoint 2010
 Designed ...
What’s New in SharePoint 2013
• Core API hasn’t changed much since 2010
• Greatly expanded coverage area
 Sites, Webs, Fe...
REST API
• Another API used when building remote applications
• What is the REST API in SharePoint
 Data-centric web serv...
What’s New in SharePoint 2013
• ListData.svc deprecated
 Still available for backwards compatibility
• RESTful operations...
Reading Data
• Client Object Model
 Load and LoadQuery allow you to specify desired
fields/properties
 Can nest includes...
Creating Lists
• Client Object Model
 ListCreationInformation
• REST API
 POST
 Body includes SP.List
 Header includes...
Creating List Items
• Client Object Model
 ListItemCreationInformation
• REST API
 POST
 Body includes SP.Data.<List Na...
Updating List Items
• Client Object Model
 Same as server object model
• REST API
 POST
 Body includes SP.Data.<List Na...
Creating Custom Fields
• Client Object Model
 Fields.AddFieldAsXml
 Prototype field first to have SharePoint generate sc...
Uploading Documents
• Client Object Model
 FileCreationInformation
 JavaScript
 Use HTML5 FileReader to read
 Use Uint...
User Profiles
• Client Object Model
 PeopleManager
 Microsoft.SharePoint.Client.UserProfiles
 SP.UserProfiles.js
• REST...
Search
• Client Object Model
 KeywordQuery and SearchExecutor
 Microsoft.SharePoint.Client.Search
 SP.Search.js
• REST ...
Calling to Host Web
• Client Object Model
 Use SP.AppContextSite to get host web context
 Get SPHostUrl parameter from q...
Web Proxy
• Client Object Model
 SP.WebRequestInfo
 SP.WebProxy.invoke
• REST API
 POST
 _api/SP.WebProxy.invoke
 Bod...
Thank You
• Big thanks to the organizers, sponsors and you for making
this event possible
• Please fill out your evaluatio...
Upcoming SlideShare
Loading in...5
×

_api: The evolution of the Client Object Model and REST API for SharePoint 2013

1,321

Published on

When building SharePoint 2013 Apps, developers are restricted from using the SharePoint Server Object Model. To enable you to build fully-featured solutions using the App model, Microsoft has greatly enhanced and extended the Client Object Model and REST API. This session begins with a brief introduction to the 2010 versions of these APIs and then explores how they have evolved and how to use them effectively when building SharePoint 2013 Apps or Solutions.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,321
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

_api: The evolution of the Client Object Model and REST API for SharePoint 2013

  1. 1. _api: : The evolution of the Client Object Model and REST API for SharePoint 2013 Rob Windsor rwindsor@portalsolutions.net @robwindsor
  2. 2. About Me • Senior SharePoint Architect with Portal Solutions • Technical Contributor to the Pluralsight On-Demand Library • Microsoft MVP, MCPD, MCT • Founder and Past-President of the North Toronto .NET UG • Co-author of Prof. Visual Basic 2012 and .NET 4.5 (Wrox)
  3. 3. Client(-Side) Object Model (CSOM) • API used when building remote applications  Introduced in SharePoint 2010  Designed to be similar to the Server Object Model • Three implementations  .NET Managed, Silverlight, JavaScript  Façades on top of /_vti_bin/Client.svc • Communication with SharePoint done in batches
  4. 4. What’s New in SharePoint 2013 • Core API hasn’t changed much since 2010 • Greatly expanded coverage area  Sites, Webs, Features, Event Receivers, Site Collections  Lists, List Items, Fields, Content Types, Views, Forms  Files, Folders  Users, Roles, Groups, User Profiles, Feeds  Web Parts  Search  Taxonomy  Workflow  IRM  E-Discovery  Analytics  Business Data
  5. 5. REST API • Another API used when building remote applications • What is the REST API in SharePoint  Data-centric web services based on the Open Data Protocol (OData)  Does not completely conform to OData spec  Lack of metadata is one glaring example  Each resource or set of resources is addressable  http://<site url>/_api/web  http://<site url>/_api/web/lists  http://<site url>/_api/web/lists/getByTitle(‘Customers’)  Operations on resources map to HTTP Verbs  GET, PUT, POST, DELETE, …  Results from service returned in AtomPub (XML) or JavaScript Object Notation (JSON) format  No batching of requests
  6. 6. What’s New in SharePoint 2013 • ListData.svc deprecated  Still available for backwards compatibility • RESTful operations added to /_vti_bin/Client.svc  /_api added as an alias for /_vti_bin/Client.svc • Coverage area  Sites, Webs, Features, Event Receivers, Site Collections  Lists, List Items, Fields, Content Types, Views, Forms, IRM  Files, Folders  Users, Roles, Groups, User Profiles, Feeds  Search
  7. 7. Reading Data • Client Object Model  Load and LoadQuery allow you to specify desired fields/properties  Can nest includes to eager load child collections • REST API  Use OData query syntax  Check for continuations
  8. 8. Creating Lists • Client Object Model  ListCreationInformation • REST API  POST  Body includes SP.List  Header includes Form Digest (X-RequestDigest)  SharePoint pages include Form Digest in hidden field
  9. 9. Creating List Items • Client Object Model  ListItemCreationInformation • REST API  POST  Body includes SP.Data.<List Name>ListItem  Header includes Form Digest (X-RequestDigest)  SharePoint pages include Form Digest in hidden field
  10. 10. Updating List Items • Client Object Model  Same as server object model • REST API  POST  Body includes SP.Data.<List Name>ListItem  Header includes Form Digest (X-RequestDigest)  SharePoint pages include Form Digest in hidden field  Header includes Request Method (X-Http-Method)  Set to PATCH or MERGE  Header includes concurrency option (IF-MATCH)  Set to item etag or *
  11. 11. Creating Custom Fields • Client Object Model  Fields.AddFieldAsXml  Prototype field first to have SharePoint generate schema XML for you • REST API  POST  Body includes SP.Field<Field Type>  Header includes Form Digest (X-RequestDigest)  SharePoint pages include Form Digest in hidden field
  12. 12. Uploading Documents • Client Object Model  FileCreationInformation  JavaScript  Use HTML5 FileReader to read  Use Uint8Array and SP.Base64EncodedByteArray to encode • REST API  POST  Body contains document contents  Header includes Form Digest (X-RequestDigest)  SharePoint pages include Form Digest in hidden field  Header contains content length (Content-Length)
  13. 13. User Profiles • Client Object Model  PeopleManager  Microsoft.SharePoint.Client.UserProfiles  SP.UserProfiles.js • REST API  GET  _api/SP.UserProfiles.PeopleManager • Apps  Requires Read permission on User Profiles
  14. 14. Search • Client Object Model  KeywordQuery and SearchExecutor  Microsoft.SharePoint.Client.Search  SP.Search.js • REST API  GET  _api/search • Apps  QueryAsUserIgnoreAppPrincipal
  15. 15. Calling to Host Web • Client Object Model  Use SP.AppContextSite to get host web context  Get SPHostUrl parameter from query string • REST API  Use _api/SP.AppContextSite(@target) to get host web context  Get SPHostUrl parameter from query string  Use SP.RequestExecutor to make call
  16. 16. Web Proxy • Client Object Model  SP.WebRequestInfo  SP.WebProxy.invoke • REST API  POST  _api/SP.WebProxy.invoke  Body contains SP.WebRequestInfo
  17. 17. Thank You • Big thanks to the organizers, sponsors and you for making this event possible • Please fill out your evaluation • Please keep in touch rwindsor@portalsolutions.net @robwindsor msmvps.com/blogs/windsor
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×