我正在尝试使用Microsoft Graph API的“创建联系人”端点(文档在这里https://docs.microsoft.com/en-us/graph/api/user-post-contacts?view=graph-rest-1.0&tabs=http)来为我的用户注册新联系人。我按照API文档中的说明创建了正文,但出现以下错误:
{
"error": {
"code": "Request_BadRequest",
"message": "A value without a type name was found and no expected type is available. When the model is specified, each value in the payload must have a type which can be either specified in the payload, explicitly by the caller or implicitly inferred from the parent value.",
"innerError": {
"request-id": "daf78520-50e6-444b-97a2-779762b3e6ed",
"date": "2020-01-23T14:20:18"
}
}
}
使用的请求: 1. POST https://graph.microsoft.com/v1.0/ {{tenant_id}} /联系人; 2.发布https://graph.microsoft.com/v1.0/me/contacts; 请求正文示例:
{
"givenName": "Yulia",
"surname": "Lukianenko",
"emailAddresses": [
{
"address": "yulia@lukianenko.onmicrosoft.com",
"name": "Yulia Lukianenko"
}
],
"businessPhones": [
"+1 732 555 0102"
]
}
有人遇到这样的问题吗?您如何解决的?
预先感谢您的帮助!
答案 0 :(得分:0)
此处的POST请求不正确。 它应该是 : https://graph.microsoft.com/v1.0/me/contacts
此外,您还需要确保已向AAD中注册的应用授予“ Contacts.ReadWrite”权限。
P.S:我在您的示例中使用graphExplorer使用了相同的JSON,并成功创建了联系人。