microsoftgraph / microsoftgraph/msgraph-sdk-dotnet
Unable to get a Special Folder by name using the GraphServiceClient.
@shemogumbe is already working on this.
Since Aug 19, 2024.
- Dominant language
- C#
- Stars
- 789
- Forks
- 264
- Avg merge
- 15h 17m
- Merged PRs (30d)
- 3
Description
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 for Special.
var result = await graphClient.Me.Drive.Special["approot"].GetAsync();
This will not work, because the slash will become url encoded.
var result = await graphClient.Me.Drives["special/approot"].GetAsync();
The C# example in the docs say to do this.
var result = await graphClient.Drives["{drive-id}"].Special["{driveItem-id}"].GetAsync();
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 a DriveRequestBuilder so we can't do something like this.
var result = graphClient.Drive.Special["approot"].GetAsync();
Potential Workaround:
The only way I have found to get the drive is by specifying the entire url, but clearly this is not ideal.
var result = await graphClient.Me.Drive
.WithUrl("https://graph.microsoft.com/v1.0/drive/special/approot")
.GetAsync();
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 to DriveRequestBuilder or add handling for null drive-id in DrivesRequestBuilder.
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).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.