-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to get a Special Folder by name using the GraphServiceClient. #2624
Comments
Thanks for raising this @MaxxDelusional Aside from the workaround suggested, you can pull in the drive Id as below. var myDrive = await graphClient.Me.Drive.GetAsync();
var result = await graphClient.Drives[myDrive.Id].Special["approot"].GetAsync(); This is covered in a section of the docs at the link as to why the requestbuilders are not present due to large API surface increasing the SDK to a very large size. |
It seems weird to make an extra call to the Graph API, just to grab a value that isn't actually needed, but I understand the desire to keep the SDK as small as possible. If there was a way to provide a relative url to the I tried this, but it's not supported.
|
At the moment you can't pass a relative url. You can however use the var result = await graphClient.Me.Drive
.WithUrl($"{graphClient.RequestAdapter.BaseUrl}/drive/special/approot")
.GetAsync(); |
This is flag as requiring my feedback. In my opinion, I still feel the Graph Client should be able to make a one-to-one call with the Graph API. But it's really up to the Graph team to decide if they want to support it or not. |
Recently I have had some random issue with this code: var driveItem = await graphClient.Me.Drive.GetAsync().ConfigureAwait(false);
string driveId = driveItem!.Id!; This have given me an permission error. In the documentation it says that It feels like this is something that has started recently. And I don't always get this error. But I had this problem while I was debugging, and changed to: var result = await graphClient.Me.Drive
.WithUrl($"{graphClient.RequestAdapter.BaseUrl}/drive/special/approot")
.GetAsync();
string driveId = result!.Id!.Split("!")[0]; This only requires the Then I tried to old code again, and then it started to worked. And it continued to work even if the reinstalled the application. Either way, I also wished it was easier to access special folders. |
Problem:
According to the docs, the request for a special folder should be
GET /me/drive/special/{name}
, however, there is no way to construct this path using the Graph SDK.What I tried:
This does not work, because
DriveRequestBuilder
does not contain a definition forSpecial
.This will not work, because the slash will become url encoded.
The C# example in the docs say to do this.
But there is no
drive-id
to specify. Attempting to use null or empty string as the drive id created an invalid request url.BaseGraphServiceClient
does not contain aDriveRequestBuilder
so we can't do something like this.Potential Workaround:
The only way I have found to get the drive is by specifying the entire url, but clearly this is not ideal.
Side Question: Is there a way to get the baseUrl from an instance of GraphServiceClient? Or any way to build a url with a relative path?
Suggestion:
Add
SpecialRequestBuilder
toDriveRequestBuilder
or add handling for null drive-id inDrivesRequestBuilder
.The docs should also be updated, as the current C# example doesn't work. (You shouldn't need a drive-id, but the docs say to specify one).
The text was updated successfully, but these errors were encountered: