Giter Site home page Giter Site logo

Comments (7)

bcameron1231 avatar bcameron1231 commented on July 18, 2024

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.

from pnpjs.

patrick-rodgers avatar patrick-rodgers commented on July 18, 2024

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.

from pnpjs.

juliemturner avatar juliemturner commented on July 18, 2024

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.

from pnpjs.

ahwitz avatar ahwitz commented on July 18, 2024

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?

from pnpjs.

juliemturner avatar juliemturner commented on July 18, 2024

You have a trailing / in your URL.. works fine with _ in the path.

from pnpjs.

ahwitz avatar ahwitz commented on July 18, 2024

That easy - we're set, can close this whenever y'all want. Thanks for the help!

from pnpjs.

github-actions avatar github-actions commented on July 18, 2024

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.

from pnpjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.