【问题标题】:Search mails using graph api使用图形 API 搜索邮件
【发布时间】: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

【问题讨论】:

    标签: microsoft-graph-api


    【解决方案1】:

    根据文档 - Known limitation,您只能访问登录用户自己的邮箱。不支持搜索委托邮箱。尝试编写查询来搜索您自己的消息。

    希望这可以帮助

    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多