I have created some folders in SharePoint 2013 List and added some items into this. Now I want to fetch items from a specific folder using javascript or maybe REST. Please provide me with the solution.

Note its a custom SP list, not Library.

2 Answers 2


You can use Rest API to fetch all items from SharePoint list. Below is sample code to fetch all items from SharePoint list using Rest API.

function getListItems(webUrl, listTitle, viewXml) {
var url = webUrl + "/_api/web/lists/getbytitle('" + listTitle + "')/getitems";
var queryPayload = {
    'query': {
        '__metadata': {
            'type': 'SP.CamlQuery'
        'ViewXml': viewXml
return $.ajax({
    url: url,
    method: "POST",
    contentType: "application/json;odata=verbose",
    data: JSON.stringify(queryPayload),
    headers: {
        "X-RequestDigest": $("#__REQUESTDIGEST").val(),
        "Accept": "application/json; odata=verbose"
function getAllFolderItems(webUrl, listTitle) {
var viewXml = '<View Scope="RecursiveAll"><Query><Where><Eq><FieldRef Name="FSObjType" /><Value Type="Integer">1</Value></Eq></Where></Query></View>';
var data = getListItems(webUrl, listTitle, viewXml);
data.done(function(data) {
    var items = data.d.results;
    for (var i = 0; i < items.length; i++) {
    function(error) {

References : Retrieve folders and sub folders from document library by REST call

Working with folders and files with REST

  • Thanks for the help. I am using some alternate solution using javascript and it worked. I am adding solution below as Answer.
    – Akhilesh
    Commented Nov 14, 2017 at 9:07

Add added one more line above CAML Query.

 camlQuery.set_viewXml("<View ><Query><Where><Eq><FieldRef" Name='columnName' />"<Value Type='Text'>" + SomeValue + "</Value></Eq></Where></Query></View > ");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.