【发布时间】:2022-12-10 13:51:03
【问题描述】:
我们正在使用 Microsoft Graph API 列表和发送电子邮件。新要求是搜索电子邮件。当尝试以下 URL 时,我们会收到错误。有人可以建议这是否是搜索邮件消息的正确 api 吗?或者缺少什么样的权限?
网址:https://graph.microsoft.com/v1.0/search/query (documentation here)
使用以下请求正文时出错:"Application permission is only supported for the following entity types:site, list, listItem, drive and driveItem."
{
"requests": [
{
"entityTypes": [
"message"
],
"query": {
"queryString": "hello"
},
"region": "NAM",
"from": 0,
"size": 25
}
]
}
错误返回::
"code": "System.UnauthorizedAccessException",
"message": "Application permission is only supported for the following entity types:site, list, listItem, drive and driveItem.",
"target": "",
"httpCode": 403
当尝试更改主体以获取列表时,正如预期的那样,它没有返回列表,因为我们只有 mail.readwrite 权限。
{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "contoso"
},
"region": "NAM",
"sharePointOneDriveOptions": {
"includeContent": "privateContent,sharedContent"
}
}
]
}
错误返回:
"code": "System.UnauthorizedAccessException",
"message": "Access to ListItem in Graph API requires the following permissions: Sites.Read.All or Sites.ReadWrite.All. However, the application only has the following permissions granted: Mail.ReadWrite, Mail.Read",
"target": "",
"httpCode": 403
【问题讨论】: