How to retrieve all SharePoint Online List Items using Rest API


We can fetch data from SharePoint in various ways - CSOM (client side object model), JSOM (JavaScript Object Model), Server Object Model, Graph API, Rest API.

REST API has been one of the most popular choice for developers. Major advantage is that REST is faster, universally accepted standard, platform independent.

With SharePoint, you can quickly test the REST call in your browser (try url from address bar) to check the returned response before actually using it.

REST API to get all items from SharePoint List/Document Library

Use GetByTitle('[List Name]')
https://[Tenant].sharepoint.com/sites/[SiteName]/_api/web/lists/GetByTitle('[ListName]')/items
This gets all list items from selected list
[Tenant] = name of your tenant
[SiteName] = Name of Site Collection / Sub site
[ListName] = Name of your SharePoint list

Get only selected column

Append ?$select=[Column Name]
https://[Tenant].sharepoint.com/sites/[SiteName]/_api/web/lists/GetByTitle('[ListName]')/items
?$select=Title
This gets Title field value of all list items from selected list

Get multiple columns

Append ?$select=[Column Name 1,Column Name 2]
https://[Tenant].sharepoint.com/sites/[SiteName]/_api/web/lists/GetByTitle('[ListName]')/items
?$select=Title,Date
This gets Title and Date field value of all list items from selected list



You can further filter, order and sort columns in the REST query.
This link can be used with an AJAX function in your HTML and JQuery/JavaScript code to process and display the results ==> data.d.

The REST call will work with any language - .Net, JAVA, PHP, HTML, etc.



















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap