_api: The evolution of the Client Object Model and REST API for SharePoint 2013
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

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

  • 1,955 views
Uploaded 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......

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.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,955
On Slideshare
1,955
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
13
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. _api: : The evolution of the Client Object Model and REST API for SharePoint 2013 Rob Windsor rwindsor@portalsolutions.net @robwindsor
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. Search • Client Object Model  KeywordQuery and SearchExecutor  Microsoft.SharePoint.Client.Search  SP.Search.js • REST API  GET  _api/search • Apps  QueryAsUserIgnoreAppPrincipal
  • 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. Web Proxy • Client Object Model  SP.WebRequestInfo  SP.WebProxy.invoke • REST API  POST  _api/SP.WebProxy.invoke  Body contains SP.WebRequestInfo
  • 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