Retrieve list items using Rest API in SharePoint Online Office 365 or SharePoint 2016 or SharePoint 2013

Retrieve list items using Rest API in SharePoint Online

Here we will discuss how we can retrieve list items using Rest API in SharePoint online Office 365. The same code will work fine in both SharePoint 2016 as well as SharePoint 2013. If you have not started yet SharePoint 2016, you can check a few articles.

Here we will use a button and on button click, we will retrieve the list items. We will add the HTML and rest API code inside a script editor web part which we will add inside a web part page.

SharePoint deveopment training course

HTML Code:


<input type=”button” id=”btnSubmit” value=”Get List Data using Rest API” />


<div id=”divResults”></div>

Also read few articles on:
How to retrieve all lists and libraries using Rest API in SharePoint online Office 365 or SharePoint 2013?

How to get content database size using PowerShell in SharePoint 2016 and using SharePoint server object model

How to use set field value in Nintex Forms for Office 365 in SharePoint Online?

Rest API Code:
Below is the full rest API code.

Here also we have used _spPageContextInfo.webAbsoluteUrl to get the absolute url of the site which we have used in the Rest endpoint. You can check out _spPageContextInfo javascript or jquery variable in SharePoint 2013 for more information how we can use _spPageContextInfo.

Then in onQuerySucceeded method we are retrive all the lists in for each loop. And we are binding the data into the <div id=”divResults”></div>

Here we are trying to retrieve list items from MyCompanyInfo list which has two columns
– Title
– Industry

To retrieve all list item we are building the rest api end point url like below:
var fullUrl = _spPageContextInfo.webAbsoluteUrl + “/_api/web/lists/getByTitle(‘MyCompanyInfo’)/items”;

Similarly if you want to retrieve based filter conditions, you can build url like below, here it will retrieve items whose id is greater than 3.

var fullUrl = _spPageContextInfo.webAbsoluteUrl + “/_api/web/lists/GetByTitle(‘MyCompanyInfo’)/items?$filter=Id ge 3″;

<script src=””></script>


$(function () {

$(“#btnSubmit”).on(“click”, function () {




function getListData() {

var fullUrl = _spPageContextInfo.webAbsoluteUrl + “/_api/web/lists/getByTitle(‘MyCompanyInfo’)/items”;


url: fullUrl,

type: “GET”,

headers: {

“accept”: “application/json;odata=verbose”,

“content-type”: “application/json;odata=verbose”,


success: onQuerySucceeded,

error: onQueryFailed



function onQuerySucceeded(data) {

var listItemInfo = ”;

$.each(data.d.results, function (key, value) {

listItemInfo += ‘<b>Title:</b> ‘ + value.Title + ‘ – <b>Industry:</b> ‘ + value.Industry + ‘<br />’;




function onQueryFailed() {




Once you Save the code and click on the button, it will display all the items from the MyCompanyInfo list.

Retrieve list items using Rest API in SharePoint Online
Retrieve list items using Rest API in SharePoint Online

Hope this will be helpful.

Check out Best Alternative to InfoPath -> Try Now

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)


About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site

View all posts by Bijay Kumar →