Closed ahwitz closed 3 months ago
Hi, I've taken a look but I haven't been able to reproduce. However, I was testing using Browser and not Node. So will continue to try and replicate.
Did another test and just learned that if the folder is not found (i.e. the call to getFolderByServerRelativePath returns 404) you will get back an empty array of files vs a 404 when you call folder.files().
Not sure if that is what you are seeing here, but we are otherwise not able to reproduce this issue.
Ok, figured this out but took a bit of checking. The getFolderByServerRelativePath
endpoint (and a few others) ONLY takes a non-encoded URL. So, the problem is you have %20 in the folder name... if you remove that it'll work. We will add to the docs about the endpoint needing to not be encoded.
Thanks, y'all - @juliemturner, I've converted the %20
to a space and still getting the same result.
Since we're dealing with character encodings, there is actually an underscore in the final folder directory, like:
const folder = await this.spInstance.getFolderByServerRelativePath(
"/sites/Finance/Shared Documents/Economics/Source_Reports/"
);
...but other than that, the _url
param is:
{
_url: "https://nesthealthcares.sharepoint.com/sites/Finance/_api/web/getFolderByServerRelativePath(decodedUrl='%2Fsites%2FFinance%2FShared%20Documents%2FEconomics%2FNavinet_Reports%2F')"
}
Also, I tried the folderFromServerRelativePath
logic that I see in the docs PR, and this structure:
const folderBase2 = folderFromServerRelativePath(this.spInstance, filepath);
console.log("folderBase2", folderBase2);
const folder2 = await folderBase2();
console.log("folder2", folder2);
const files2 = await folder2.files();
console.log("files2", files2);
...gives me a 404 with the same decodedUrl=
URL in the debug. I'm still a bit new to Sharepoint, but if the user has access to the file (per a file in that folder loading), would they also have access to the folder, and if not, does MS obscure 401/403 as 404 like this?
You have a trailing / in your URL.. works fine with _ in the path.
That easy - we're set, can close this whenever y'all want. Thanks for the help!
This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.
Major Version
4.x
Minor Version Number
2.0
Target environment
NodeJS
Additional environment details
NodeJS, MSAL, in Linux, Windows, or WSL on developer machines or in Azure Functions.
Expected or Desired Behavior
Folder.files() call as documented should work.
Observed Behavior
In the "Steps to reproduce" below: 1) is the printout of the folder, which does not throw any kind of error 2) is the printout of
files()
, which prints an empty array (same if the.getFolderByServerRelativePath().files()
is chained) 3) is the printout of a call to get an individual file inside the folder, which succeedsWe'd expect the
.files()
call to load some sort of metadata so we can list files in the folder. Also worth noting that what is a function is referenced as a property at the end of this documentation.Steps to Reproduce