Skip to content

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

@Holystewe

Description

@Holystewe

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions