0

Accessing the SharePoint 2013 API, I have been trying to get files names in each folder in a library and getting errors. I am using Alteryx.

DownloadData Error:

{"error":{"code":"-2147024809, System.ArgumentException","message":{"lang":"en-US","value":"Value does not fall within the expected range."}}}<

My URLs are below:

https://team.global.ABCCompany/sites/ABCDataLake/_api/web/GetFolderByServerRelativeUrl('/FolderName')/Files

And

https://team.global.ABCCompany/sites/ABCDataLake/_api/sp.appcontextsite(@target)/web/getfolderbyserverrelativeurl('FolderName')/Files

  1. Might you be able to spot a mistake?
  2. In the 2nd one, should I be filling in anything to replace "@target"?
  3. Is there a preferred method, assuming one works?

Many thanks as always.

2 Answers 2

1

You can use SharePoint REST API endpoint in below format to get the files from specific folder inside document library:

https://contoso.sharepoint.com/sites/SPConnect/_api/web/GetFolderByServerRelativeUrl('/sites/SPConnect/Shared%20Documents/Folder1')/Files

You can even get properties associated with files using single API call like:

https://contoso.sharepoint.com/sites/SPConnect/_api/web/GetFolderByServerRelativeUrl('/sites/SPConnect/Shared%20Documents/Folder1')/Files?$expand=ListItemAllFields

Similar threads:

  1. How to get all properties of a Site Page using REST API?
  2. List all Files with all Properties/Fileds for a given folder Path
1
  • 1
    Thank you Ganesh!
    – ChasEpes
    Mar 2 at 22:30
1

You need to provide the "Folder URL" which is a server relative path of a folder. Let's say you need the file names from "Folder1" folder of "ABCLibrary" document library.

URL: https://team.global.ABCCompany/sites/ABCDataLake/_api/web/GetFolderByServerRelativeUrl('/ABCLibrary/Folder1')/Files

In the second one, you are making a cross-domain requests, so you have added SP.AppContextSite(@target) in which you need to pass ?@target='<host web url>' to the endpoint URI.

URL: https://team.global.ABCCompany/sites/ABCDataLake/_api/sp.appcontextsite(@target)/web/getfolderbyserverrelativeurl('/ABCLibrary/Folder1')/Files?@target='https://team.global.ABCCompany/sites/ABCDataLake'

1
  • Thank you Divya!
    – ChasEpes
    Mar 2 at 22:30

Your Answer

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

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