0

I'm using the following REST endpoint for getting all items from a list:

https://myCompany.sharepoint.com/sites/portal/myName/_api/web/Lists/GetByTitle('MyFolderTitle')/Items?$select=FileLeafRef,FileRef

I'm having weird problems with it. For example I have a subfolder with 2 pdf files, they have the same permissions, same everything, uploaded at the same time. I can see them both when viewing them online and download them and everything, but with the REST call, I only get 1 file back.

What could be the reason for that behavior? Any help or hints would be appreciated because I'm losing my mind on this...

Thanks!

1 Answer 1

0

In your endpoint it is return the data of folder and the files inside the folder.

To work with files and folder in document library you can refer below endpoints.

to return all files and folder at a specific folder URL

https://myCompany.sharepoint.com/sites/portal/myName/_api/Web/GetFolderByServerRelativeUrl(<folder url>)?$expand=Folders,Files

To return only all files at a specific folder URL

https://myCompany.sharepoint.com/sites/portal/myName/_api/Web/GetFolderByServerRelativeUrl(<folder url>)?$expand=Files

And if you want to work with endpoint mentioned in question

$.ajax({  
url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/Lists/GetByTitle('LibraryName')/Items",  
type: 'GET',  
dataType: "json",  
headers: {  
    "Accept": "application/json;odata=verbose",  
    "content-type": "application/json; odata=verbose",  
    "X-RequestDigest": $("#__REQUESTDIGEST").val()  
},  
success: function (data) {  
    for (var i = 0; i < data.d.results.length; i++) {  
    //to check for not a folder
        if (data.d.results[i].FileSystemObjectType != 1) {            
        }  
    }  
},  
error: function (request, error) {  
    console.log(JSON.stringify(request));  
}  
});

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.