Your SlideShare is downloading. ×
0
chris.beckett@obeflow.com
www.obeflow.com
(425) 522-3727
Enterprise Content Management and Business Process Automation Sof...
About Chris Beckett
24+10
MCM
MCT
MCSE
MCPD
Entrepreneur
Solutions Architect
Systems Engineer
Trainer and Author
chris.bec...
Agenda
Introduction to
SharePoint Web
Services
Working with
REST and ODATA
Services
Programming
with the
REST API
Agenda
Introduction to
SharePoint Web
Services Working with
REST and ODATA
Services
Programming
with the
REST API
Available SharePoint Web Services
• Open Standards
• RPC Model
• Protocol Agnostic
• XML
• Microsoft Proprietary
• Batch R...
SharePoint 2010 Web Service Access
SOAP CSOM REST
Lists and Libraries
Site and List Settings
Site Security
Workflow
Search...
SharePoint 2010 Web Service Clients
SOAP CSOM REST
JavaScript
Silverlight
.NET
Windows Phone
Other Languages
InfoPath Rece...
SharePoint 2013 Web Service Access
SOAP CSOM REST
Lists and Libraries
Site and List Settings
Site Security
Workflow
Search...
SharePoint 2010 Web Service Clients
SOAP CSOM REST
JavaScript
Silverlight
.NET
Windows Phone
Other Languages
InfoPath Rece...
What is SOAP?
Created by Microsoft in 1998 / W3C Standard
Protocol Agnostic / Common to use HTTP
RPC Message Pattern (Requ...
SharePoint Web Service Addresses
Web Service Web Service Address
Search http://<site>/_vti_bin/search.asmx
User Profiles h...
SOAP Request Message Format
SOAP Envelope
SOAP Body
Method and
Parameters
SOAP Considerations
• All Versions of SharePoint
• Ubiquitous
• Protocol Agnostic
• Language Agnostic
• Access to Enterpri...
What is the CSOM?
Proprietary Microsoft SharePoint Client API
.NET / Silverlight / WP7 / ECMAScript
Mimics Server-side Obj...
CSOM Architecture
CSOM (.NET)
Create a Context
Load the Context
Execute Query
Access Properties
CSOM Considerations
• Efficient for Batch Operations
• Familiar for SharePoint
Developers
• Supports LINQ Queries
• Works ...
What is REST?
Representational State Transfer
Web Addressable Resources / Hyperlink-able
Maps CRUD operations with HTTP Ve...
Anatomy of a REST Call
Request URLHTTP Method
HTTP Body with
Encoded DataHeaders
HTTP Status Codes
Status Code Description
200 OK The server successfully processed the request.
400 Bad Request The server...
Data Encoding - ATOMPUB
Data Encoding - JSON
REST Considerations
• Efficient for simple operations
• Familiar to Web Developers
• HTTP and open standards
• Very JavaSc...
Anatomy of a REST
Call
 Using the List Data Service
 Using the Client REST API
 Data Encoding
Agenda
Introduction to
SharePoint Web
Services
Working with
REST and ODATA
Services Programming
with the
REST API
ODATA Operations and Parameters
GET (Retrieve)
POST (Create)
PUT (Update All Fields)
DELETE (Delete)
MERGE (Update Specifi...
ODATA Query Operators
Area Supported Not Supported
Numeric
Comparisons
• Lt, Le
• Gt, Ge
• Eq, Ne
• add, sub, mul, div, mo...
Querying with
ODATA
 $Top and $Skip
 $Filter
 $Select
 $OrderBy
 $Expand
Agenda
Introduction to
SharePoint Web
Services
Working with
REST and ODATA
Services
Programming
with the
REST API
Programming Tools / Platforms
• C++
• C#
• VB.NET
• PHP
• Java
• Datajs
• jQuery
• Sencha Rest Connector
• JayData
• Reque...
List Data Service Access Points
Area Access Point
Lists http://server/site/_vti_bin/ListData.svc
List http://server/site/_...
Client REST Service Access Points
Area Access Point
Site http://server/site/_api/site
Web http://server/site/_api/web
List...
Visual Studio
List Data Service 2010 (ECMA Script)
Request Executor (SharePoint 2013)
Calling SharePoint
REST APIs
 HTTP Verbs
 Accept Headers
 Authentication
 eTags and Concurrency
More Information
Choose the Right API set with SharePoint 2013
http://msdn.microsoft.com/en-us/library/jj164060.aspx
Compl...
Tools and Utilities
LinqPad – Learn ODATA Queries with Linq
http://www.linqpad.net/
RESTClient – Java Application for Test...
Questions
Thank you for attending!
Please complete your
evaluations. Your feedback is
appreciated 
chris.beckett@obeflow....
Understanding and programming the SharePoint REST API
Upcoming SlideShare
Loading in...5
×

Understanding and programming the SharePoint REST API

8,382

Published on

In this presentation I introduce the SharePoint REST API for SharePoint 2010 and 2013 and how to get started programming with ODATA and REST.

Published in: Technology

Transcript of "Understanding and programming the SharePoint REST API"

  1. 1. chris.beckett@obeflow.com www.obeflow.com (425) 522-3727 Enterprise Content Management and Business Process Automation Software as a Service Understanding and Programming the SharePoint REST API
  2. 2. About Chris Beckett 24+10 MCM MCT MCSE MCPD Entrepreneur Solutions Architect Systems Engineer Trainer and Author chris.beckett@obeflow.com @sharepointbits blog.sharepointbits.com
  3. 3. Agenda Introduction to SharePoint Web Services Working with REST and ODATA Services Programming with the REST API
  4. 4. Agenda Introduction to SharePoint Web Services Working with REST and ODATA Services Programming with the REST API
  5. 5. 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 SOAP Web Services (ASMX) Client Side Object Model (CSOM/JSOM) REST API (ODATA)
  6. 6. SharePoint 2010 Web Service Access SOAP CSOM REST Lists and Libraries Site and List Settings Site Security Workflow Search Managed Metadata User Profiles Publishing
  7. 7. SharePoint 2010 Web Service Clients SOAP CSOM REST JavaScript Silverlight .NET Windows Phone Other Languages InfoPath Receive InfoPath Submit BCS WCF Connector
  8. 8. 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
  9. 9. SharePoint 2010 Web Service Clients SOAP CSOM REST JavaScript Silverlight .NET Windows Phone Other Languages InfoPath Receive InfoPath Submit BCS WCF Connector Deprecated
  10. 10. 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
  11. 11. SharePoint Web Service Addresses Web Service Web Service Address Search http://<site>/_vti_bin/search.asmx User Profiles http://<site>/_vti_bin/userprofileservice.asmx Sites http://<site>/_vti_bin/sites.asmx Lists http://<site>/_vti_bin/lists.asmx Permissions http://<site>/_vti_bin/permissions.asmx Copy http://<site>/_vti_bin/copy.asmx 31 Public Web Services (25+6) in SharePoint
  12. 12. SOAP Request Message Format SOAP Envelope SOAP Body Method and Parameters
  13. 13. 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
  14. 14. What is the CSOM? Proprietary Microsoft SharePoint Client API .NET / Silverlight / WP7 / ECMAScript Mimics Server-side Object Model Proprietary Message Transfer Format
  15. 15. CSOM Architecture
  16. 16. CSOM (.NET) Create a Context Load the Context Execute Query Access Properties
  17. 17. 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
  18. 18. What is REST? Representational State Transfer Web Addressable Resources / Hyperlink-able Maps CRUD operations with HTTP Verbs Commonly uses JSON for Data Messages
  19. 19. Anatomy of a REST Call Request URLHTTP Method HTTP Body with Encoded DataHeaders
  20. 20. HTTP Status Codes Status 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
  21. 21. Data Encoding - ATOMPUB
  22. 22. Data Encoding - JSON
  23. 23. 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
  24. 24. Anatomy of a REST Call  Using the List Data Service  Using the Client REST API  Data Encoding
  25. 25. Agenda Introduction to SharePoint Web Services Working with REST and ODATA Services Programming with the REST API
  26. 26. 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
  27. 27. ODATA Query Operators Area Supported Not Supported Numeric Comparisons • Lt, Le • Gt, Ge • Eq, Ne • add, sub, mul, div, mod • round, floor, ceiling String Comparisons • startsWith • substringof • Eq • Ne • endsWith, trim • substring, replace, concat • tolower, toupper Date and Time Functions • day(), month(), year() • hour(), minute(), second() • DateTimeRangesOverlap
  28. 28. Querying with ODATA  $Top and $Skip  $Filter  $Select  $OrderBy  $Expand
  29. 29. Agenda Introduction to SharePoint Web Services Working with REST and ODATA Services Programming with the REST API
  30. 30. Programming Tools / Platforms • C++ • C# • VB.NET • PHP • Java • Datajs • jQuery • Sencha Rest Connector • JayData • RequestExecutor Compiled Languages JavaScript Libraries
  31. 31. List Data Service Access Points Area Access Point Lists http://server/site/_vti_bin/ListData.svc List http://server/site/_vti_bin/ListData.svc/Tasks
  32. 32. Client REST Service Access Points Area Access Point Site http://server/site/_api/site Web http://server/site/_api/web Lists http://server/site/_api/web/lists List http://server/site/_api/web/lists/getbytitle(‘Tasks’) User Profile http://server/site/_api/SP.UserProfiles.PeopleManager Search http://server/site/_api/search Publishing http://server/site/_api/publishing
  33. 33. Visual Studio
  34. 34. List Data Service 2010 (ECMA Script)
  35. 35. Request Executor (SharePoint 2013)
  36. 36. Calling SharePoint REST APIs  HTTP Verbs  Accept Headers  Authentication  eTags and Concurrency
  37. 37. More Information Choose the Right API set with SharePoint 2013 http://msdn.microsoft.com/en-us/library/jj164060.aspx Complete Basic Operations with the SharePoint 2013 Client Library http://msdn.microsoft.com/en-us/library/fp179912.aspx Programming using the SharePoint 2013 REST Service http://msdn.microsoft.com/en-us/library/fp142385.aspx SharePoint 2010 Web Services http://msdn.microsoft.com/en-us/library/ee705814(v=office.14).aspx Accessing SharePoint 2010 Lists by Using WCF Data Services http://msdn.microsoft.com/en-us/library/hh134614(v=office.14).aspx
  38. 38. Tools and Utilities LinqPad – Learn ODATA Queries with Linq http://www.linqpad.net/ RESTClient – Java Application for Testing REST Programming https://code.google.com/p/rest-client/ CAML Designer for SharePoint 2010 and 2013 http://sharepoint.biwug.be/SitePages/Caml_Designer.aspx Fiddler – HTTP Debugger http://www.fiddler2.com/fiddler2/ SharePoint 2013 Search Query Tool http://sp2013searchtool.codeplex.com/
  39. 39. Questions Thank you for attending! Please complete your evaluations. Your feedback is appreciated  chris.beckett@obeflow.com (425) 522-3727 @sharepointbits blog.sharepointbits.com
  1. A particular slide catching your eye?

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

×