Wednesday 10 May 2017

Get All SharePoint list items using REST API

Solution:


Here I create 1 variable as follow:


1)      url : REST API with list name

var url = "/_api/Web/Lists/GetByTitle('CRUDList')/Items";

Function:


            function getItems(url) {
                $.ajax({
                    url: _spPageContextInfo.webAbsoluteUrl + url,
                    type: "GET",
                    headers: {
                        "accept": "application/json;odata=verbose",
                    },
                    success: function (data) {
                        console.log(data.d.results);
                    },
                    error: function (error) {
                        alert(JSON.stringify(error));
                    }
                });
            }

Function call:


getItems(url);


Feel free to revert in-case of any query...

Product Applies To:


·         SharePoint Server 2013

·         SharePoint Foundation 2013


 

No comments:

Post a Comment