microsoftgraph / microsoftgraph/msgraph-sdk-dotnet

Unable to get a Special Folder by name using the GraphServiceClient.

Open
#2,624 6 comments 3 reactions 1 assignee View on GitHub

@shemogumbe is already working on this.

Since Aug 19, 2024.

Needs: Attention :wave: type:question
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.