8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 1/37
Understanding the REST API ofSharePoint 2013 SPSSTHLM17Paolo Pialorsi [email protected] 25 th, 2014
SharePoint
Stockh
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 2/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 3/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 4/37
Agenda
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 5/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 6/37
JavaScriptLibrary
SilverlightLibrary
.Net CLRLibrary
Custom Client Code
ClientServer
_api is new alias for _vti_bin/client.svc
RESTODataJSON
CSOM
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 7/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 8/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 9/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 10/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 11/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 12/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 13/37
http(s):// {Host Name} / {site} /_api/ {namespace} / {object}{property}
{indexer(index)}{method({parameter}
Web Application Hostname
Site Collection (Optional)
API Namespace
Operation
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 14/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 15/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 16/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 17/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 18/37
Operator Description Example
add Addition /Products?$filter=Price add 5 gt 10
sub Subtraction /Products?$filter=Price sub 5 gt 10
mul Multiplication /Products?$filter=Price mul 2 gt 2000
div Division /Products?$filter=Price div 2 gt 4
mod Modulo /Products?$filter=Price mod 2 eq 0
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 19/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 20/37
Function Description Example
string substring(string string, int pos, int length)
Returns a substring of the string provided inthe first argument, starting from the integerposition provided in the second argument andstopping after a number of charactersprovided in the third integer argument.
substring(CompanyNam
string tolower(string string)Returns a string that is the lowercaseconversion of the string provided as the stringargument
tolower(CompanyNamefutterkiste'
string toupper(string string)Returns a string that is the uppercaseconversion of the string provided as the stringargument
tolower(CompanyNamefutterkiste'
string trim(string string) Returns a string trimmed from spaces, basedon the string provided as argument. trim(CompanyName) eq
string concat(string string1, string string2) Returns a string that is the concatenation ofthe two string arguments provided.
concat(concat(City,', '), Germany'
int day(DateTime datetimeValue)Returns an integer that corresponds to theday of the datetime value provided asargument.
day(BirthDate) eq 8
int hour(DateTime datetimeValue)Returns an integer that corresponds to thehours of the datetime value provided asargument.
hour(BirthDate) eq 1
int minute(DateTime datetimeValue)Returns an integer that corresponds to theminutes of the datetime value provided asargument.
minute(BirthDate) eq 0
int month(DateTime datetimeValue)Returns an integer that corresponds to themonth of the datetime value provided as
argument.
month(BirthDate) eq 12
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 21/37
Function Description Example
int second(DateTime datetimeValue)Returns an integer that corresponds to theseconds of the datetime value provided asargument.
second(BirthDate) eq 0
int year(DateTime datetimeValue)Returns an integer that corresponds to the
year of the datetime value provided asargument.year(BirthDate) eq 1948
double round(double doubleValue)Returns a double number that is the roundedvalue of the double value provided asargument.
round(Freight) eq 32
decimal round(decimal decimalValue)Returns a decimal number that is the roundedvalue of the decimal value provided asargument.
round(Freight) eq 32
double floor(double doubleValue)Returns a double number that is the floorvalue of the double value provided asargument.
floor(Freight) eq 32
decimal floor(decimal datetimeValue)
Returns a decimal number that is the floor
value of the decimal value provided asargument. floor(Freight) eq 32
double ceiling(double doubleValue)Returns a double number that is the ceilingvalue of the double value provided asargument.
ceiling(Freight) eq 33
decimal ceiling(decimal datetimeValue)Returns a decimal number that is the ceilingvalue of the decimal value provided asargument.
ceiling(Freight) eq 33
bool IsOf(type value) Returns a boolean value stating if the targetentity is of the type provided as argument. isof('NorthwindModel.O
bool IsOf(expression value, type targetType)
Returns a boolean value stating if the
expression provided as the first argument, isof the type provided as the second argument. isof(ShipCountry,'Edm.
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 22/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 23/37
http://devbook.sp2013.local/_api/web/lists/GetByTitle(Documents')/Ro
der/Files?$expand=Author&$select=Name,Author,TimeLastModified&$orderby=TimeLastModified%20desc,Name&$skip=20&$top=10&$filter=substringof('Chapter',Name)%20eq%20true
Query Part Explanation
$expand=Author Expands the related object Author, while retrieving the docum
$select=Name,Author,TimeLastModified Retrieves the fields Name, Author, and TimeLastModified.
$sort=TimeLastModified desc,Name Sorts the output descending by TimeLastModified, and ascenName.
$skip=20 Skips the first 20 items of the resultset (i.e. the first two pagitems).
$top=10 Retrieves only the first 10 items of the resultset (i.e. the thirditems).
$filter= substringof('Chapter',Name) eq true Retrieves only files with a file name that contains the literla "C
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 24/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 25/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 26/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 27/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 28/37
{"d": {
"GetContextWebInformation": {"__metadata": {
"type":"SP.ContextWebInformation"},
"FormDigestTimeoutSeconds":1800,"FormDigestValue":"0x8B48E76BAF6C86A17CCEC50F9A29E7CBB85816B883417C52C10C67FB19760517B774CD71E43517635386DE585E92A0262779824E5E0C7ECA905436A048AC85AC,08 Jan 2013 01:11:57 -0000","LibraryVersion":"15.0.4420.1017",
"SiteFullUrl":"http://devbook.sp2013.local",
"SupportedSchemaVersions": {"results": ["14.0.0.0","15.0.0.0"
]},"WebFullUrl":"http://devbook.sp2013.local"}
}}
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 29/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 30/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 31/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 32/37
App Web Host Web
SP.RequestExecutor.js
IFrame(AppWebProxy.ASPX)
2) Emit IFrame
3) Download proxy page
4) Make REST/CSOM call
5) Get response data
6) Get data back to app
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 33/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 34/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 35/37
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 36/37
jQuery.ajax({url: "http://hostname/_api/contextinfo",
type: "POST",headers: {"Authorization": "Bearer " + accessToken,"accept": "application/json;odata=verbose","contentType": "text/xml"
},})
8/11/2019 SPSSTHLM17 - Understanding the REST API of SharePoint 2013
http://slidepdf.com/reader/full/spssthlm17-understanding-the-rest-api-of-sharepoint-2013 37/37