SPTECHCON - Get Some REST - Taking Advantage of the SharePoint 2013 REST API
Upcoming SlideShare
Loading in...5
×
 

SPTECHCON - Get Some REST - Taking Advantage of the SharePoint 2013 REST API

on

  • 374 views

 

Statistics

Views

Total Views
374
Slideshare-icon Views on SlideShare
360
Embed Views
14

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 14

http://www.slideee.com 14

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

    SPTECHCON - Get Some REST - Taking Advantage of the SharePoint 2013 REST API SPTECHCON - Get Some REST - Taking Advantage of the SharePoint 2013 REST API Presentation Transcript

    • Taking Advantage of the SharePoint 2013 REST API
    • CKS:DEV The SharePoint Cowboy Patterns & Practices Eric Shupps www.sharepointcowboy.com eshupps@binarywave.com facebook.com/sharepointcowboy @eshupps
    • Introduction Basic Operations JavaScript Endpoints Advanced Methods Windows 8
    • INTRODUCTION
    • 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’)
    • Client.svc Server OM Content DB READ CREATE UPDATE DELETE POST GET PUT, MERGE, DELETE
    • http://contoso/_api/items/GetById(1)?$select=Title,ID Location Service Resource Path Query Options
    • Local Current Context Request Digest Remote OAuth Access Token Cross Domain Request Executor SP.WebProxy HTTP WebRequest Context Info Cross Domain
    • ENDPOINTS
    • Site Web Publishing User Profiles Webs Features Event Receivers Users Profiles Activity Lists Items Pages Variations Navigation Query Results Suggestions Search Taxonomy Managed Metadata
    • BASIC OPERATIONS
    • • SP.RequestExecutor • accept: "application/json;odata=verbose"
    • http://<site collection>/<site>/_api/sites/features/GetById(guid’<value>’) http://<site collection>/<site>/_api/sites/eventreceivers View Event Receivers 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} }} Create a Site Get Feature
    • http://<site collection>/<site>/_api/lists Get All Lists http://<site collection>/<site>/_api/lists/GetByTitle(‘Shared Documents’) Get List http://<site collection>/<site>/_api/lists/GetByTitle(‘Shared Documents’)/items/GetById(0) Get List Item http://<site collection>/<site>/_api/lists/GetByTitle(‘Shared Documents’)/items/ GetById(1)?$select=Title,ID Get List Item with Specific Properties
    • http://<site collection>/<site>/_api/search/query?queryText=‘Value’ Simple Term http://<site collection>/<site>/_api/search/query?queryText=‘PreferredName: Robert Smith’ Item Property http://<site collection>/<site>/_api/search/suggest?queryText=‘quarterly sales’ Suggestions
    • http://<site collection>/<site>/_api/social.following/followed Get Followed Users http://<siteCollection>/<site>/_api/social.following/my/followeddocumentsuri Get Followed Documents http://<site collection>/<site>/_api/sp.userprofiles.peoplemanager/getmysuggestions Get Suggestions http://<siteCollection>/<site>/_api/sp.userprofiles.peoplemanager/ getpeoplefollowedby(accountName=@v)?@v='domainuser' Get Followers
    • ADVANCED METHODS
    • http://<site>/_api/Web/Lists(guid’<value>′)/Items(1)/FieldValuesAsHtml HTML Values http://<site>/_api/web/lists/getbytitle(‘Products’)/items()/?$select=Title, Price,effectivebasepermissions Get Permissions http://<site>/_api/web/lists/getbytitle('Products')/items()?$select=Title, Price,Supplier_/Title&$expand=Supplier_/Title Join
    • http://<site>/_api/web/lists/getbytitle(‘Products’)/items/?$filter=Price gt 30000 Filter with Comparison http://<site>/_api/web/lists/getbytitle(‘Products’)/items()? $select=Title,Price,Supplier_/Title&$expand=Supplier_/Title&$filter=Supplier_/Title eq ‘Acme’ Join with Filter http://<site collection>/<site>/_api/web/lists('<guid>')/items$top=10 Top ‘N’ Results
    • 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 Create 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 Edit a List Item
    • • Used to prevent replay attacks • Updates will fail without digest value • Local • $("#__REQUESTDIGEST").val() • Remote • POST to /_api/contextinfo
    • 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