• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Taking Advantage of the SharePoint 2013 REST API
 

Taking Advantage of the SharePoint 2013 REST API

on

  • 11,258 views

 

Statistics

Views

Total Views
11,258
Views on SlideShare
11,245
Embed Views
13

Actions

Likes
3
Downloads
136
Comments
0

2 Embeds 13

https://twitter.com 10
http://uscin2012v2 3

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Taking Advantage of the SharePoint 2013 REST API Taking Advantage of the SharePoint 2013 REST API Presentation Transcript

    • Get Some REST: SharePoint 2013 REST API's Eric Shupps SharePoint Server MVP
    • Sponsored by: Real-time application monitoring, event management, and operational health metrics for Microsoft SharePoint Reduce troubleshooting time by up to 30% Increase efficiency and improve user satisfaction Avoid downtime and costly outages Meet or exceed service level agreements Maximize investment in current infrastructure Visit us on the web at www.binarywave.com
    • About Me The SharePoint Cowboy Eric Shupps CKS:DEV Patterns & Practices www.sharepointcowboy.com eshupps@binarywave.com facebook.com/sharepointcowboy @eshupps
    • Agenda Introduction Endpoints Basic Operations Advanced Methods JavaScript Windows 8
    • INTRODUCTION
    • Background HTTP-based web service architecture that uses nouns and verbs to define operations Noun: “Items” Verbs: GET, POST, PUT, DELETE OData provides metadata, object typing and query semantics for underlying data structure (WCF data services) /items(0) Client Object Model service (client.svc) processes queries, interacts with server OM, returns formatted response (JSON, XML) /items/GetByTitle(‘foo’)
    • Implementation READ UPDATE DELETE GET PUT, MERGE, DELETE Client.svc CREATE POST Server OM Content DB
    • Structure http://contoso/_api/items/GetById(1)?$select=Title,ID Location Service Resource Path Query Options
    • Security Local Remote Cross Domain Current Context OAuth Request Executor Request Digest Access Token SP.WebProxy Context Info Cross Domain HTTP WebRequest
    • Gotchas  OData Spec != SharePoint REST  No request batching  Must specify “odata=verbose” in header  Default response format is ATOM  Use CSOM notation when accessing static methods and properties  Some requests may not return default values due to processing overhead
    • ENDPOINTS
    • SharePoint 2013 REST Endpoints Site Web Publishing User Profiles Search Taxonomy Webs Lists Pages Users Query Results Managed Metadata Features Items Variations Profiles Suggestions Navigation Activity Event Receivers
    • Metadata You Must Be Joking!
    • BASIC OPERATIONS
    • Sites Get Feature http://<site collection>/<site>/_api/sites/features/GetById(guid’<value>’) View Event Receivers http://<site collection>/<site>/_api/sites/eventreceivers Create a Site http://<site collection>/<site>/_api/web/webinfos/add { 'd' :{ 'parameters': { '__metadata': {'type': 'SP.WebInfoCreationInformation' }, 'Url': 'RestSubWeb', 'Title': 'RestSubWeb', 'Description': 'rest created web', 'Language':1033, 'WebTemplate':'sts', 'UseUniquePermissions':false} }}
    • Lists Get All Lists http://<site collection>/<site>/_api/lists Get List http://<site collection>/<site>/_api/lists/GetByTitle(‘Shared Documents’) Get List Item http://<site collection>/<site>/_api/lists/GetByTitle(‘Shared Documents’)/items/GetById(0) Get List Item with Specific Properties http://<site collection>/<site>/_api/lists/GetByTitle(‘Shared Documents’)/items/ GetById(1)?$select=Title,ID
    • Search Simple Term http://<site collection>/<site>/_api/search/query?queryText=‘Value’ Item Property http://<site collection>/<site>/_api/search/query?queryText=‘PreferredName:Robert Smith’ Suggestions http://<site collection>/<site>/_api/search/suggest?queryText=‘quarterly sales’
    • Social Get Followed Users http://<site collection>/<site>/_api/social.following/followed Get Followed Documents http://<siteCollection>/<site>/_api/social.following/my/followeddocumentsuri Get Suggestions http://<site collection>/<site>/_api/sp.userprofiles.peoplemanager/getmysuggestions Get Followers http://<siteCollection>/<site>/_api/sp.userprofiles.peoplemanager/ getpeoplefollowedby(accountName=@v)?@v='domainuser'
    • ADVANCED METHODS
    • Queries HTML Values http://<site>/_api/Web/Lists(guid’<value>′)/Items(1)/FieldValuesAsHtml Get Permissions http://<site>/_api/web/lists/getbytitle(‘Products’)/items()/?$select=Title, Price,effectivebasepermissions Join http://<site>/_api/web/lists/getbytitle('Products')/items()?$select=Title, Price,Supplier_/Title&$expand=Supplier_/Title
    • Sorting & Filtering Filter with Comparison http://<site>/_api/web/lists/getbytitle(‘Products’)/items/?$filter=Price gt 30000 Join with Filter http://<site>/_api/web/lists/getbytitle(‘Products’)/items()? $select=Title,Price,Supplier_/Title&$expand=Supplier_/Title&$filter=Supplier_/Title eq ‘Acme’ Top ‘N’ Results http://<site collection>/<site>/_api/web/lists('<guid>')/items$top=10
    • CRUD Operations Create a List Item url: http://site url/_api/web/lists/GetByTitle(‘Test')/items method: POST body: { '__metadata': { 'type': 'SP.Data.TestListItem' }, 'Title': 'Test'} headers: Authorization = "Bearer " + accessToken X-RequestDigest = form digest value accept: "application/json;odata=verbose" content-type: "application/json;odata=verbose" content-length:1024 Edit a List Item url: http://site url/_api/web/lists/GetByTitle(‘Test')/items(item id) method: POST body: { '__metadata': { 'type': 'SP.Data.TestListItem' }, 'Title': 'TestUpdated'} headers: Authorization = "Bearer " + accessToken X-RequestDigest = form digest value “IF-MATCH”: etag or “*” “X-HTTP-Method”:”MERGE”, accept: "application/json;odata=verbose" content-type: "application/json;odata=verbose" content-length:1024
    • Form Digest  Used to prevent replay attacks  Updates will fail without digest value  Local  $("#__REQUESTDIGEST").val()  Remote  POST to /_api/contextinfo
    • JAVASCRIPT
    • Operations  Async GET/POST operations using AJAX library  Cross-Domain Library  SP.RequestExecutor  Remote Apps: SP.AppContextSite with @target  JSON response  accept: "application/json;odata=verbose"
    • Authorization  Remote  Use CSOM to set context  Sites/Webs/Lists – Handled by appweb not hostweb  Pass token in request – RequestExecutor  Local  Use current context
    • Retrieving SharePoint list data with jQuery, REST and AJAX PROVIDER HOSTED APP
    • WINDOWS 8
    • Operations  XAML  List items with specific fields  Async – HTTPClient, HTTPClientHandler  ATOM  LINQ
    • Authorization  Domain Credentials  Permissions  Enterprise Authentication  Private Networks
    • Uploading Documents to SharePoint using REST WINDOWS 8 APP
    • Sponsored by: Real-time application monitoring, event management, and operational health metrics for Microsoft SharePoint Reduce troubleshooting time by up to 30% Increase efficiency and improve user satisfaction Avoid downtime and costly outages Meet or exceed service level agreements Maximize investment in current infrastructure Visit us on the web at www.binarywave.com
    • Resources Description Link Programming Using the SharePoint 2013 REST Service http://bit.ly/TUwC9N OData URI Conventions http://bit.ly/Ytgdz4 Using the SharePoint 2013 REST Service http://bit.ly/YPHif5 SharePoint 2013 Search REST API http://bit.ly/ZqzOuM Configuring SharePoint 2013 Search REST for Anonymous Users http://bit.ly/152vFoy SharePoint 2013 REST TypeScript Library http://sprestts.codeplex.com