introduction to the sharepoint 2013 rest api

21
Introduction to the SharePoint 2013 REST API

Upload: sparkhound-inc

Post on 17-Nov-2014

237 views

Category:

Technology


3 download

DESCRIPTION

SharePoint 2013 has extended the REST interface to provide easy access to data within your SharePoint farm. The REST interface opens the SharePoint 2013 development platform to standard Web technologies and languages. This presentation will cover the basics of getting started with the REST service and provide beneficial examples of using REST.

TRANSCRIPT

Page 1: Introduction to the SharePoint 2013 REST API

Introduction to the SharePoint 2013 REST API

Page 2: Introduction to the SharePoint 2013 REST API

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

3

AGENDA

REST and ODATA OverviewSharePoint 2013 REST APIDemos

Page 4: Introduction to the SharePoint 2013 REST API

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

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

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

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

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

9

DEMO

Page 10: Introduction to the SharePoint 2013 REST API

10

Critical ToolsFiddlerCore jQuery libraryBrowser developer toolsAdvanced REST Client (Chrome App)Postman (Chrome App)

Page 11: Introduction to the SharePoint 2013 REST API

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

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

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

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

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

16

Creating list items

Page 17: Introduction to the SharePoint 2013 REST API

17

Delete list items

Page 18: Introduction to the SharePoint 2013 REST API

18

Update List Items

Page 19: Introduction to the SharePoint 2013 REST API

19

Current REST IssuesREST API does have support for

Managed MetadataWorkflows

Lacks batching support *

Page 20: Introduction to the SharePoint 2013 REST API

20

Questions?

Page 21: Introduction to the SharePoint 2013 REST API

21