You are using an older browser that might negatively affect how this site is displayed. Please update to a modern browser to have a better experience. Sorry for the inconvenience!

SHAREPOINT – REST API


By: Santhosh

SharePoint is a tool to connect people and information. It provides a central site for sharing information with other users. SharePoint is web-based and accessible from anywhere in the world via an internet connection.

SharePoint provides places to store and share ideas, information, communication and documents. The sites facilitate team participation. The document libraries allow for easy checking in and checking out of documents and version control.

REST – REpresentation State Transfer.

API – Application Programming Interface.

SharePoint can be integrated using REST API, CAML Query and SOAP. With the help of its rich pre-defined REST API, we can develop application in any platform to utilize SharePoint features.

Example to Get a data: 

$. ajax ({ 

   url: URL, //THE ENDPOINT 

   method: "GET", 

   headers: {“Accept": "application/JSON; odata=verbose”}, 

   success: function (data) { 

        console.log (data.d. email) //RESULTS HERE!! 

   } 

}); 


sharepoint rest api

OData query operators supported in the SharePoint REST service

Example API: http://server/site/_api/web/lists(‘guid’)/items?$select=Title,Products/Name&$expand=Products/Name

sharepoint rest api

Below, I have listed some Rest API list and it provides the details as to how to get the values from the API. This is much helpful for beginners.

Site Information API: 

Endpoint url: http://server/site/_api/Web/SiteUserInfoList

Users Information API:

  • To get Current User Information by using this API

Endpoint url: http://server/site/_api/Web/ currentUser

  • To get all site users information by using this API

Endpoint url: http://server/site/_api/Web/siteusers

  • To get particular group site users information by using this API

Endpoint url: http://server/site/_api/Web/sitegroups(GroupId)/users

  • To get particular group site users information by using this API

Endpoint url: http://server/site/_api/Web/sitegroups(GroupId)/users/getbyid(UserId)

 

Group Information API: 

  • To get all group information:

Endpoint url: http://server/site/_api/Web/sitegroups

  • To get group information by using groupID:

Endpoint url: http://server/site/_api/Web/sitegroups/GetById(GroupId)

  • To get a user group:

Endpoint url: http://server/site/_api/Web/ GetUserById(“+UserID+”)/Groups

Endpoint url: http://server/site/_api/Web/ currentuser/? $expand=groups’

 

LISTS Information API:

  • To get all properties from the list:

Endpoint url: http://server/site/_api/web/lists

  • To get a particular property of the list:

Endpoint url: http://server/site/_api/web/lists/getbytitle(‘Title’)

  • To get the selected fields list:

Endpoint url: http://server/site/_api/web/lists/getbytitle(‘Title’)/Items?select=ID,Title

  • To get the selected fields list by using filter:

Endpoint url: http://server/site/_api/web/lists/getbytitle(‘Title’)/Items?select=ID,Title&$filter=((ID eq 1) and (Title ne ‘zzz’))

  • To get the selected fields list by using Expand:

Endpoint url: http://server/site/_api/web/lists/getbytitle(‘Title’)/Items?select=*,list2/Title,list3/Title&$filter=((ID eq 1) and (Title ne ‘zzz’))&$expand=list2, list3

 

Postman – Chrome REST Application  

We can utilize Google Chrome’s application – Postman to test the REST API calls before using it in our application. This application features output formats in JSON or XML which can be printed automatically.

Pass the Accept Header as application/JSON; odata=verbose to initiate the API calls. Also, you need to use interceptor to get the login cookies from the browser directly. After sending the API request, one may get

Result as:

{ 

    "d": { 

        "results": [ 

            { 

(Array values) 

            } 

     } 

}