使用Microsoft Graph API添加备用电子邮件地址

4

我正在尝试从.Net Core应用程序使用Microsoft Graph API添加备用电子邮件。

Microsoft Graph中的user类没有提供用于添加附加邮件标识的属性。


你还有关于这个问题的疑虑吗?如果有,请随时告诉我。 - Fei Xue - MSFT
你到底尝试了什么?你卡在哪里了? - Nico Haase
3个回答

5
您可以使用Azure AD Graph将邮件ID添加到otherMails中。以下是更新此属性的示例:
PATCH: https://graph.windows.net/{tenant}/me?api-version=1.6
authorization: bearer {access_token}

{
"otherMails":["test@test.com"]
}

请参考以下链接,了解用户实体和更新用户REST:

实体和复杂类型参考 | Graph API 参考

更新用户


是的,我在Azure AD中看到了“OtherMails”属性。但我想在Microsoft Graph API中实现这一点。Microsoft Graph API中是否有任何属性? - Sridevi
目前,Microsoft Graph REST不支持此属性。如果您希望Microsoft Graph REST支持此功能,可以从此处提交反馈。如果您仍然喜欢使用Microsoft Graph,则可以使用扩展作为解决方法。 - Fei Xue - MSFT

1
以下是用于检索备用电子邮件的C#代码。
Select(u => new {
    u.DisplayName,
    u.Mail,
    u.UserPrincipalName,
    u.OtherMails
})
.GetAsync();  

0

您可以从Graph API文档中的用户的"otherMails"属性中获取备用电子邮件。

请注意,这仅在选择时返回,因此您需要包括查询参数"$select=otherMails"才能看到它。

GET https://graph.microsoft.com/v1.0/users/USER_ID?$select=otherMails
authorization: bearer {access_token}

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(otherMails)",
    "@odata.id": "https://graph.microsoft.com/v2/YOUR_AAD_TENANT/directoryObjects/USER_ID/Microsoft.DirectoryServices.User",
    "otherMails": [
        "altEmail@website.com"
    ]
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接