Introduction to the SharePoint 2013 REST API
-
Upload
sparkhound-inc -
Category
Technology
-
view
242 -
download
3
description
Transcript of Introduction to the SharePoint 2013 REST API
![Page 1: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/1.jpg)
Introduction to the SharePoint 2013 REST API
![Page 2: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/2.jpg)
2
About Me
SharePoint Solutions Architect at Sparkhound in Baton Rougehttp://www.sparkhound.com/pages/blogs.aspx@codygrosLeader of the Baton Rouge SharePoint User Group – www.brspug.com
![Page 3: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/3.jpg)
3
AGENDA
REST and ODATA OverviewSharePoint 2013 REST APIDemos
![Page 4: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/4.jpg)
4
REST IntroductionREST = REpresentational State TransferA simpler alternative to SOAP based on HTTP request/response pairsClient sends HTTP requests that target specific resources using unique URIs
![Page 5: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/5.jpg)
5
What is OData?
Odata is a standardized REST API for Data AccessODATA API maps CRUD operations to HTTP verbshttp://www.odata.org
![Page 6: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/6.jpg)
6
HTTP MethodsGET
Returns an item or array of itemsPOST
Creates a new itemPUT
Updates an item (replaces all fields with default values)
PATCH or MERGEUpdates an item in place (existing values are retained)
DELETEDeletes an item
![Page 7: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/7.jpg)
7
OData URIs
URI has three partsService root URIResource pathQuery string options
Service Root URI Resource Path to a SharePoint Object Query String Options
![Page 8: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/8.jpg)
8
OData Query Option Parameters$select
Specifies which columns to retrieve$filter
Selecting what items to retrieve$orderby
Sorting items$expand
Retrieve results that are usually deferred$top
Select how many items to return$skip
Selecting which row to start at
![Page 9: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/9.jpg)
9
DEMO
![Page 10: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/10.jpg)
10
Critical ToolsFiddlerCore jQuery libraryBrowser developer toolsAdvanced REST Client (Chrome App)Postman (Chrome App)
![Page 11: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/11.jpg)
11
Request HeadersAccept
what type of data you want to receiveContent-type
What type of data you are sending in the request body
X-HTTP-MethodWhich operation to perform
X-RequestDigestEncrypted security value required for updates
IF-MATCHPasses Etag value to control optimistic concurrency
![Page 12: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/12.jpg)
12
AJAX Calls
$.ajax() function is part of the core jQuery libraryURI end pointAccept header: application/json;odata=verbose
![Page 13: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/13.jpg)
13
Request DigestProvides security mechanism to protect against replay attacksSharePoint pages has element with ID __REQUESTDIGESTPassed in request by using X-RequestDigest header<site url>/_api/contextinfo
![Page 14: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/14.jpg)
14
Creating / Updating You must include item type metadata for inserts & updatesAll write operations must pass valid request digest value
![Page 15: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/15.jpg)
15
List Item Type MetadataEach SharePoint list has a unique type for its list items
String based type value must be passed will all inserts and updates
![Page 16: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/16.jpg)
16
Creating list items
![Page 17: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/17.jpg)
17
Delete list items
![Page 18: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/18.jpg)
18
Update List Items
![Page 19: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/19.jpg)
19
Current REST IssuesREST API does have support for
Managed MetadataWorkflows
Lacks batching support *
![Page 20: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/20.jpg)
20
Questions?
![Page 21: Introduction to the SharePoint 2013 REST API](https://reader034.fdocuments.net/reader034/viewer/2022052214/54698ba7af7959c32b8b5759/html5/thumbnails/21.jpg)
21