Can anyone please help me with that?

Suppose my list name is: Country in which I created 5 folders with different country names, then inside that folder I created their state names.

So scenario is that, first I want to make a dropdown of those country names and then using that dropdown I want to filter and show state name in a Data table (jQuery data table or manually created DataTable).

List screenshot: click to view screenshot

After opening folder it data is in this manner: click to view screenshot

Code Sample:

    function getProjectLists() {
    //    /_api/web/lists/getbytitle('EOT')/items?$select=FileLeafRef,FileRef&$filter=FSObjType eq 1
    var url = _spPageContextInfo.webAbsoluteUrl + " /_api/web/lists/getbytitle('EOT')/items?$filter=FSObjType eq 0";
    return getAjaxResponse(url).then(function (response) {
        hotWorkPermitProjects = response.d.results;
function getAjaxResponse(url) {
        var def = $.Deferred();
        return $.ajax({
            url: url,
            type: "GET",
            headers: {
                "accept": "application/json; odata=verbose"
            success: function (response) { def.resolve(response); },
            error: function (err) { def.reject(err); }
        return def.promise();

1 Answer 1


You can get the folders inside SharePoint list using multiple ways.

  • Using filter on content type
  • Using filter on FSObjType
  • Using CAML query with GetItems endpoint
  • Using /Folders endpoint

Check below reference links for more detailed answers:

  1. REST with $filter for List Items in Sharepoint 2013
  2. Get folders from list using SharePoint Rest API
  3. REST API Get all folder and subfolder in one call API

Also, you can fetch the list items inside particular folder using REST API, based on folder selection in dropdown.

Check Getting all the items in a folder section in this article: SharePoint REST API and Lists with Folders

  • Not able to get data. Can you please paste working code. Commented Jul 22, 2021 at 15:19
  • Are you getting any error? Can you add the current code you have to your original question by editing it? Commented Jul 22, 2021 at 16:35
  • Thanks Ganesh. Code added. Commented Jul 23, 2021 at 5:21

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.