0

I am trying to retrieve a nested folder using the Graph API sdk in C# with the following folder structure:

(site) site.sharepoint.com -> (folder) 2022 -> (folder) October -> (folder) 25

Using this code:

var dayDrive = await graphClient
    .Sites["site.sharepoint.com"]
    .Drives["2022"]
    .Root
    .Children["October"]
    .Children["25"]
    .Request()
    .GetAsync();

However this fails with code:

Code: invalidRequest
Message: Invalid request

But this doesn't make sense, why is this failing and how can I retrieve the nested folder I need?

Tiny Wang
  • 10,423
  • 1
  • 11
  • 29
Azhari
  • 535
  • 5
  • 20
  • since I don't have the same test resource with yours, so I shared 2 options, could you pls take a try? By the way, could you pls kindly let me know if it didn't work for you with the latest error message? – Tiny Wang Oct 26 '22 at 02:24
  • Drives["2022"] will not work. You need to use drive id, not name of the folder – user2250152 Oct 26 '22 at 06:48

1 Answers1

0

try

await graphClient.Sites["site.sharepoint.com"].Drives["2022"]
                            .Root.ItemWithPath("/October/25").Children
                            .Request().GetAsync();

or

await graphClient.Sites["site.sharepoint.com"].Drive
                            .Root.ItemWithPath("/2022/October/25").Children
                            .Request().GetAsync();
Tiny Wang
  • 10,423
  • 1
  • 11
  • 29