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.

Ganesh Sanap - MVP
  • 44,918
  • 21
  • 30
  • 61
ChasEpes
  • 109
  • 1
  • 8

2 Answers2

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'

Divya Sharma
  • 1,461
  • 11
  • 26
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
Ganesh Sanap - MVP
  • 44,918
  • 21
  • 30
  • 61