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

GraphClient PatchAsync returns null values when Updating a User on B2C tenant #2816

Open
Holystewe opened this issue Jan 30, 2025 · 2 comments
Labels
Status: No recent activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close

Comments

@Holystewe
Copy link

Holystewe commented Jan 30, 2025

If I request a PatchAsync to update a user on a B2C tenant with GraphClient, it should return the updated user. This worked a week ago, now the GraphClient response is always null, even if the user is properly updated (i've double checked on the B2C tenant to see if it's updated).

Here's the lines of code where i perform the actual call:

    public async Task<DefaultResponse<B2CUserDto?>> UpdateB2CUserAsync(CreateUserRequest request, string id)
    {
        try
        {
            var user = await graphClient.Users[id].GetAsync();

            if (user is null)
                return new()
                {
                    IsOk = false,
                    Message = $"Failed to retrieve user with Id {id}",
                    StatusCode = ApplicationStatusCode.NotFound
                };

            var mappedUser = b2CUserMapper.Map(request);

            var response = await graphClient.Users[id].PatchAsync(mappedUser);

            if (response is null)
                return new()
                {
                    IsOk = false,
                    Message = $"Failed to update user with Id {id}",
                    StatusCode = ApplicationStatusCode.ServerError
                };

            return new()
            {
                IsOk = true,
                Message = "User successfully updated",
                Value = b2CUserMapper.MapToDto(request, id)
            };
        }
        catch (Exception ex)
        {
            return new(ex.Message);
        }
    }

Here's the response I got two days ago:

Image

And the actual response is null instead.

@andrueastman
Copy link
Member

Thanks for raising this @Holystewe

Any chance you are able to follow the guidance from the link below to log the HTTP request? This will help ascertain if the API is returning json or a successfull response with no content.

https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/blob/main/docs/logging-requests.md

@andrueastman andrueastman added the status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close label Feb 5, 2025
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: No recent activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close
Projects
None yet
Development

No branches or pull requests

2 participants