Azure GraphServiceClient exception "Delta patch payload must contain @context : #$delta" when updating user

MT 6 Reputation points
2021-11-23T20:40:31.547+00:00

As per the title, I'm trying to update an Azure B2C user with my API using the Microsoft.Graph NuGet package. I've recently deleted and recreated my app registration on Azure and in my infinite wisdom didn't write down which scopes it had been permitted.

Users access my API with an access token issued by B2C from a separate web client, so I'm presuming the scopes my API needs would come under application permissions (no signed in user) rather than delegated permissions (with a signed in user), and I think the User.ReadWrite.All permission should cover it?

I'm questioning this because the requests have stopped working yet there have been no changes to the code. The code is below:

IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
    .Create(configuration[$"{Constants.AzureAdB2C}:ClientId"])
    .WithTenantId(configuration[$"{Constants.AzureAdB2C}:Domain"])
    .WithClientSecret(configuration[$"{Constants.AzureAdB2C}:ClientSecret"])
    .Build();

IAuthenticationProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);

GraphServiceClient graphClient = new GraphServiceClient(authProvider);

User azureUser = await graphClient.Users[azureId]
    .Request()
    .Select(e => new
    {
        e.OtherMails
    })
    .GetAsync();

azureUser.OtherMails = userEmails;

await graphClient.Users[azureId]
    .Request()
    .UpdateAsync(azureUser);

Retrieving the details is fine but on the last line to update the user I get the exception Delta patch payload must contain @context : #$delta. I can't find any reference to this anywhere and can't find or remember where I got the original code above from. Can anybody advise where I'm going wrong?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,678 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,656 questions
0 comments No comments
{count} votes