I'm upgrading client code that uses the Microsoft Graph nuget package from v4.54 to v5.4. I have code that works in v4 that updates the identities for a user exactly like How to update identities collection for existing B2C User using Microsoft Graph and SDK.
All the updated functions in my code works, e.g. creating users, adding users to groups, etc., except for updating or adding identities to the user. After updating the Post to a Patch as required, the code fails with an unexpected error:
Microsoft.Graph.Models.ODataErrors.MainError
Code: Request_BadRequest
Message: signInType cannnot be null or empty [sic]
I've run the request through Fiddler and the signInType is definitely not null.
Code before
user.Identities.Add(new ObjectIdentity
{
SignInType = "emailAddress",
Issuer = issuer,
IssuerAssignedId = issuerAssignedId
});
await client.Users[user.Id].Request().UpdateAsync(user);
Code after
user.Identities.Add(new ObjectIdentity
{
SignInType = "emailAddress",
Issuer = issuer,
IssuerAssignedId = issuerAssignedId
});
await client.Users[user.Id].PatchAsync(user);
I've also tried creating a new user object for the patch (same error):
var identities = user.Identities;
identities.Add(new ObjectIdentity
{
SignInType = "emailAddress",
Issuer = issuer,
IssuerAssignedId = issuerAssignedId
});
var requestBody = new User
{
Identities = identities
};
await client.Users[user.Id].PatchAsync(requestBody );
Has anyone successfully updated the Identities collection on a User with Graph v5.x?