microsoftgraph / microsoftgraph/msgraph-sdk-dotnet

Querystring Select option is missing during PostAsync() with v5 SDK

Open
#1,760 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

Describe the bug
In SDK v4 we could do the following call:

var user = new(){...}
var result = await graphClient.Users.Request().Select("mailNickname").AddAsync(user);

This would create a new user with the fields defined in the user object. One of those fields is mailNickname. The result gave a User back with the fields from the AddAsync and extra selected mailNickname field.

With the new SDK we can't give Select QueryParameters parameters in the PostAsync method.
In order to get the complete user again, we need to do 2 calls in the new v5 SDK.

var result = await graphClient
    .Users
    .PostAsync(user);

result = await graphClient
    .Users[result.Id]
    .GetAsync(rc =>
    {
        rc.QueryParameters.Select = new string[] { "id", "displayName", "mail", "mailNickname", "mobilePhone", "..." };
    });

How can we do this better/more optimized?

Expected behavior
Want to do a Post with select in a single call just like in v4 of the SDK.

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 tracing the Users.PostAsync(user) entry point and its request configuration, then compare it with the v4 Users.Request().Select(...).AddAsync flow described in the issue. Determine where query parameters could be supplied for the POST request and verify that a single call returns the selected fields, including mailNickname.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.