Skip to content
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

DriveItemItemRequestBuilder.PatchAsync is using RequestConfiguration<DefaultQueryParameters> #2369

Open
24-Lukaras opened this issue Mar 3, 2024 · 1 comment

Comments

@24-Lukaras
Copy link

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.

@sant2006
Copy link

sant2006 commented Apr 2, 2024

Same is the case with ContentRequestBuilder PutAsync for uploading small file contents. PutAsync is using DefaultQueryParameters, no option to select SharePoint ids.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants