microsoftgraph / microsoftgraph/msgraph-sdk-dotnet

DriveItemItemRequestBuilder.PatchAsync is using RequestConfiguration<DefaultQueryParameters>

Open
#2,369 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug: metadata OpenApi
Dominant language
C#
Stars
789
Forks
264
Avg merge
15h 17m
Merged PRs (30d)
3

Description

Issue

In my case I have tried to create a sharepoint folder, which I wanted to further modify by changing its content type to document set.
I wanted to use SharePointIds of driveItem.
However creating the folder with:

var folder = new DriveItem()
{
    Folder = new Folder(),
};
await client.Drives[driveId].Root.ItemWithPath(folderPath).PatchAsync(folder, config => {
    //change of config.QueryParameters
});

does not return sharePointIds by default, so it needs $select=sharepointIds query parameter, which is supported by the api but not with the DefaultQueryParameters.

Probable solution

Creating DriveItemItemRequestBuilderPatchQueryParameters with $select and $expand queryParams properties which would be used similar way as DriveItemItemRequestBuilderGetQueryParameters in the DriveItemItemRequestBuilder.GetAsync should in my opinion resolve this.

Hack I have tried

I have also tried to solve this with a workaround of creating my own QueryParameters class and using it as such:

public class DriveItemPatchQueryParameters : DefaultQueryParameters
{
    [QueryParameter("%24select")]
    public string[]? Select { get; set; } = [ "sharepointIds" ];
}
await client.Drives[driveId].Root.ItemWithPath(folderPath).PatchAsync(folder, config => {
    config.QueryParameters = new DriveItemPatchQueryParameters();
});

However the RequestInformation.AddQueryParameters gets the query string properties with typeof(T).GetProperties() which means only base type (DefaultQueryParameters in this case) properties are used. If source.GetType().GetProperties() would be used it could allow more customization. But I think the current behavior is intended. I am just mentioning this for consideration.

Contribution question

I would try to implement this on my own, but considering I do not have any experience with open source contribution I would like to ask for some kind of "go ahead" from someone knowledgeable in case you think it is appropriate.

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.

Research direction

Start by comparing DriveItemItemRequestBuilder.PatchAsync with DriveItemItemRequestBuilder.GetAsync, then inspect RequestInformation.AddQueryParameters and the mentioned query-parameter types. Done means PATCH configuration supports the $select and $expand parameters needed to return sharePointIds, without relying on the custom workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.