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

client.Users.GetByIds.PostAsGetByIdsPostResponseAsync Does not allow for $select parameter #2796

Open
mligtenberg opened this issue Jan 14, 2025 · 1 comment
Labels
dependency:metadata Awaiting fix from core dependency project module type:bug A broken experience

Comments

@mligtenberg
Copy link

Describe the bug

I would like to select a group of users with their known identities by doing the following request:

POST /v1.0/users/getByIds?$select=id,displayName,identities HTTP/1.1
Host: graph.microsoft.com
Content-Type: application/json
Content-Length: 48

{"ids":["aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"]}

This should be translate to something like the following in C#

var user = await client.Users
    .GetByIds.PostAsGetByIdsPostResponseAsync(new GetByIdsPostRequestBody()
    {
        Ids = ["aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"],
    }, cfg => 
    {
        cfg.QueryParameters.Select = ["id", "displayName", "identities"];
    });

However the cfg.QueryParameters.Select property is not available for client.Users.GetByIds.PostAsGetByIdsPostResponseAsync() request

Expected behavior

The Select query parameter should be available in the PostAsGetByIdsPostResponseAsync configuration body, as it is available in the actual api

How to reproduce

Use the following code snippet:

var user = await client.Users
    .GetByIds.PostAsGetByIdsPostResponseAsync(new GetByIdsPostRequestBody()
    {
        Ids = ["aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"],
    }, cfg => 
    {
        cfg.QueryParameters.Select = ["id", "displayName", "identities"];
    });

SDK Version

5.68.1

Latest version known to work for scenario above?

No response

Known Workarounds

non,

something like the following should work, but the query parameters are ignored:

var postRequest = client.Users.GetByIds.ToPostRequestInformation(new()
{
    Ids = ["aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"]
});

postRequest.QueryParameters.Add("%24select", "id,displayName,identities");
var users = await client.RequestAdapter.SendAsync<GetByIdsPostResponse>(postRequest, GetByIdsPostResponse.CreateFromDiscriminatorValue);

Debug output

No response

Configuration

  • Dotnet version: 8.0

Other information

No response

@mligtenberg mligtenberg added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jan 14, 2025
@mligtenberg
Copy link
Author

I found a work around, the UrlTemplate is also incorrect and should be expanded.
The below code is working (though really ugly)

var requestInfo = client.Users.GetByIds.ToPostRequestInformation(new()
{
    Ids = ["aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"],
});

requestInfo.UrlTemplate += "{?%24expand,%24select}";
requestInfo.QueryParameters.Add("%24select", new [] {"id","displayName","identities","mail"});

var response = await client.RequestAdapter.SendAsync<GetByIdsPostResponse>(requestInfo, GetByIdsPostResponse.CreateFromDiscriminatorValue);

var users = response?.Value?.OfType<User>() ?? [];

@andrueastman andrueastman added dependency:metadata Awaiting fix from core dependency project module and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency:metadata Awaiting fix from core dependency project module type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

2 participants