When I'm trying to update the list of SignInNames
, I get the error: Resource <EMAIL ADDRESS> does not exist or one of its queried reference-property objects are not present
.
var currentUser = await GetUserByUserNameAsync(userId); // this gets the user
var signinNames = currentUser.SignInNames.ToList();
signinNames.Add(new SignInName
{
Type = "emailAddress",
Value = newEmailaddress
});
var data = new B2CChangeEmailAddressData()
{
SignInNames = signinNames
};
var response = await _graphApi.SendAsync(new HttpMethod("PATCH"), $"users/{userId}", null, data);
And then it returns the error. I use comparable code to update the password, that works fine. Am I overlooking something?
So, what I did was:
The first is possible, but the second isn't. I had to update the user by using the ObjectId
. So the code should be:
var currentUser = await GetUserByUserNameAsync(userId);
var path = $"users/{currentUser.ObjectId}";
var signinNames = new List<SignInName>();
signinNames.Add(new SignInName
{
Type = "emailAddress",
Value = newEmailaddress
});
var data = new B2CChangeEmailAddressData()
{
SignInNames = signinNames
};
var response = await _graphApi.SendAsync(new HttpMethod("PATCH"), path, null, data);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.