understanding and programming the sharepoint rest api
DESCRIPTION
In this presentation I introduce the SharePoint REST API for SharePoint 2010 and 2013 and how to get started programming with ODATA and REST.TRANSCRIPT
![Page 1: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/1.jpg)
[email protected](425) 522-3727
Enterprise Content Management and Business Process Automation Software as a Service
Understanding and Programmingthe SharePoint REST API
![Page 2: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/2.jpg)
About Chris Beckett
24+10MCMMCT
MCSEMCPD
EntrepreneurSolutions ArchitectSystems EngineerTrainer and Author
@sharepointbits
blog.sharepointbits.com
![Page 3: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/3.jpg)
Agenda
Introduction toSharePoint
Web Services
Working withREST and
ODATAServices
Programmingwith theREST API
![Page 4: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/4.jpg)
Agenda
Introduction toSharePoint
Web Services Working withREST and
ODATAServices
Programmingwith theREST API
![Page 5: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/5.jpg)
Available SharePoint Web Services
• Open Standards
• RPC Model
• Protocol Agnostic
• XML
• Microsoft Proprietary
• Batch RPC Model
• Client Runtime
• XML / JSON
• Open Standards
• REST Model
• HTTP Only
• ATOM / JSON
SOAPWeb Services
(ASMX)
Client Side ObjectModel
(CSOM/JSOM)
REST API(ODATA)
![Page 6: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/6.jpg)
SharePoint 2010 Web Service Access
SOAP CSOM REST
Lists and Libraries
Site and List Settings
Site Security
Workflow
Search
Managed Metadata
User Profiles
Publishing
![Page 7: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/7.jpg)
SharePoint 2010 Web Service Clients
SOAP CSOM REST
JavaScript
Silverlight
.NET
Windows Phone
Other Languages
InfoPath Receive
InfoPath Submit
BCS WCF Connector
![Page 8: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/8.jpg)
SharePoint 2013 Web Service Access
SOAP CSOM REST
Lists and Libraries
Site and List Settings
Site Security
Workflow
Search
Managed Metadata
User Profiles
Publishing
Deprecated
![Page 9: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/9.jpg)
SharePoint 2010 Web Service Clients
SOAP CSOM REST
JavaScript
Silverlight
.NET
Windows Phone
Other Languages
InfoPath Receive
InfoPath Submit
BCS WCF Connector
Deprecated
![Page 10: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/10.jpg)
What is SOAP?
Created by Microsoft in 1998 / W3C Standard
Protocol Agnostic / Common to use HTTP
RPC Message Pattern (Request/Response)
XML Schema used for Message Structures
![Page 11: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/11.jpg)
SharePoint Web Service AddressesWeb Service Web Service AddressSearch http://<site>/_vti_bin/search.asmxUser Profiles http://<site>/_vti_bin/userprofileservice.asmxSites http://<site>/_vti_bin/sites.asmxLists http://<site>/_vti_bin/lists.asmxPermissions http://<site>/_vti_bin/permissions.asmxCopy http://<site>/_vti_bin/copy.asmx
31 Public Web Services (25+6) in SharePoint
![Page 12: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/12.jpg)
SOAP Request Message Format
SOAP Envelope
SOAP Body
Method and Parameters
![Page 13: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/13.jpg)
SOAP Considerations
• All Versions of SharePoint• Ubiquitous• Protocol Agnostic• Language Agnostic
• Access to Enterprise Services
• Designed to work with Proxy• Not JavaScript Friendly• Verbose Xml Data• No Anonymous
![Page 14: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/14.jpg)
What is the CSOM?
Proprietary Microsoft SharePoint Client API
.NET / Silverlight / WP7 / ECMAScript
Mimics Server-side Object Model
Proprietary Message Transfer Format
![Page 15: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/15.jpg)
CSOM Architecture
![Page 16: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/16.jpg)
CSOM (.NET)
Create a Context
Load the Context
Execute Query
Access Properties
![Page 17: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/17.jpg)
CSOM Considerations
• Efficient for Batch Operations• Familiar for SharePoint
Developers• Supports LINQ Queries• Works with Anonymous
• Less Efficient for Simple Operations• Unfamiliar to Web
Developers• Limited # of Client Runtimes• Microsoft Proprietary
![Page 18: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/18.jpg)
What is REST?
Representational State Transfer
Web Addressable Resources / Hyperlink-able
Maps CRUD operations with HTTP Verbs
Commonly uses JSON for Data Messages
![Page 19: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/19.jpg)
Anatomy of a REST CallRequest URLHTTP Method
HTTP Body withEncoded DataHeaders
![Page 20: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/20.jpg)
HTTP Status CodesStatus Code Description
200 OK The server successfully processed the request.
400 Bad Request The server didn't understand the request.
401 Unauthorized The request requires authentication.404 Not Found The server can't find the requested
page.500 Internal Server Error
The server encountered an error.Calling a web
service requires checking the status
code to validate success
![Page 21: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/21.jpg)
Data Encoding - ATOMPUB
![Page 22: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/22.jpg)
Data Encoding - JSON
![Page 23: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/23.jpg)
REST Considerations
• Efficient for simple operations• Familiar to Web Developers• HTTP and open standards• Very JavaScript Friendly• Limited support for Anonymous
• Complex for batch operations• Unfamiliar to SharePoint
Developers• Requires knowledge of HTTP
protocol and programming
![Page 24: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/24.jpg)
Anatomy of a REST Call
Using the List Data Service
Using the Client REST API
Data Encoding
DEMO
![Page 25: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/25.jpg)
Agenda
Introduction toSharePoint
Web Services
Working withREST and
ODATAServices Programming
with theREST API
![Page 26: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/26.jpg)
![Page 27: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/27.jpg)
ODATA Operations and Parameters
GET (Retrieve)POST (Create)PUT (Update All Fields)DELETE (Delete)MERGE (Update Specific)
$filter={simple predicate}$expand={Entity}$order by={property}$skip={n}$top={n}$metadata
Operations Parameters
![Page 28: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/28.jpg)
ODATA Query Operators
Area Supported Not SupportedNumeric Comparisons
• Lt, Le• Gt, Ge• Eq, Ne
• add, sub, mul, div, mod
• round, floor, ceilingString Comparisons
• startsWith• substringof• Eq• Ne
• endsWith, trim• substring, replace,
concat• tolower, toupper
Date and Time Functions
• day(), month(), year()
• hour(), minute(), second()
• DateTimeRangesOverlap
![Page 29: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/29.jpg)
Querying with ODATA
$Top and $Skip $Filter $Select $OrderBy $Expand
DEMO
![Page 30: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/30.jpg)
Agenda
Introduction toSharePoint
Web Services
Working withREST and
ODATAServices
Programmingwith theREST API
![Page 31: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/31.jpg)
Programming Tools / Platforms
• C++• C#• VB.NET• PHP• Java
• Datajs• jQuery• Sencha Rest Connector• JayData• RequestExecutor
Compiled Languages JavaScript Libraries
![Page 32: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/32.jpg)
List Data Service Access Points
Area Access PointLists http://server/site/_vti_bin/ListData.svcList http://server/site/_vti_bin/ListData.svc/Tasks
![Page 33: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/33.jpg)
Client REST Service Access Points
Area Access PointSite http://server/site/_api/siteWeb http://server/site/_api/webLists http://server/site/_api/web/listsList http://server/site/_api/web/lists/getbytitle(‘Tasks’)User Profile http://server/site/_api/
SP.UserProfiles.PeopleManagerSearch http://server/site/_api/searchPublishing http://server/site/_api/publishing
![Page 34: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/34.jpg)
Visual Studio
![Page 35: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/35.jpg)
List Data Service 2010 (ECMA Script)
![Page 36: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/36.jpg)
Request Executor (SharePoint 2013)
![Page 37: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/37.jpg)
Calling SharePoint REST APIs
HTTP Verbs Accept Headers Authentication eTags and Concurrency
DEMO
![Page 38: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/38.jpg)
More Information
Choose the Right API set with SharePoint 2013http://msdn.microsoft.com/en-us/library/jj164060.aspx
Complete Basic Operations with the SharePoint 2013 Client Libraryhttp://msdn.microsoft.com/en-us/library/fp179912.aspx
Programming using the SharePoint 2013 REST Servicehttp://msdn.microsoft.com/en-us/library/fp142385.aspx
SharePoint 2010 Web Serviceshttp://msdn.microsoft.com/en-us/library/ee705814(v=office.14).aspx
Accessing SharePoint 2010 Lists by Using WCF Data Serviceshttp://msdn.microsoft.com/en-us/library/hh134614(v=office.14).aspx
![Page 39: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/39.jpg)
Tools and Utilities
LinqPad – Learn ODATA Queries with Linqhttp://www.linqpad.net/
RESTClient – Java Application for Testing REST Programminghttps://code.google.com/p/rest-client/
CAML Designer for SharePoint 2010 and 2013http://sharepoint.biwug.be/SitePages/Caml_Designer.aspx
Fiddler – HTTP Debuggerhttp://www.fiddler2.com/fiddler2/
SharePoint 2013 Search Query Toolhttp://sp2013searchtool.codeplex.com/
![Page 40: Understanding and programming the SharePoint REST API](https://reader033.vdocuments.site/reader033/viewer/2022061206/5481a22cb4af9f6e0d8b45a4/html5/thumbnails/40.jpg)
Questions
Thank you for attending!
Please complete your evaluations. Your feedback is appreciated
chris.beckett@obeflow.
com
(425) 522-3727
@sharepointbits
blog.sharepointbits.co
m