无法在 Microsoft Graph Api 中按收件人筛选消息.一个或多个无效节点多个、收件人、节点、消息

由网友(Serenity 宁静)分享简介:我正在尝试从 Microsoft Graph API 获取按收件人筛选的消息列表.我用于请求的网址是:https://graph.microsoft.com/beta/me/messages?$filter=toRecipients/any(r: r/emailAddress/address eq '[Email Ad...

我正在尝试从 Microsoft Graph API 获取按收件人筛选的消息列表.我用于请求的网址是:

https://graph.microsoft.com/beta/me/messages?$filter=toRecipients/any(r: r/emailAddress/address eq '[Email Address]')p>Microsoft Graph 桌面应用程序

但我得到的回应是:

{错误": {"code": "ErrorInvalidUrlQueryFilter","message": "查询过滤器包含一个或多个无效节点.",内部错误":{请求 ID":7db712c3-e337-49d9-aa8d-4a5d350d8480",日期":2016-09-28T16:58:34"}}}

一个成功的请求应该是这样的(我省略了更多的数据).

{"@odata.context": "https://graph.microsoft.com/beta/$metadata#users('99999999-9999-9999-9999-999999999999')/messages","@odata.nextLink": "https://graph.microsoft.com/beta/me/messages?$skip=10",价值": [{收件人":[{电子邮件地址": {"名称": "[名称]",地址":[电子邮件地址]"}}],}]}

如果我删除过滤器,请求就会起作用,并且我可以使用更简单的过滤器执行请求.

我的网址有问题,还是有其他方法可以提出请求?

解决方案

找了几个小时后,在office365文档中发现 toRecipients 属性不可过滤:

https://msdn.microsoft.com/en-us/office/office365/api/complex-types-for-mail-contacts-calendar#MessageResource

我猜它在图形 api 中是一样的.所以唯一的解决办法就是使用搜索.

I am trying to get a list of messages that are filtered by recipient from Microsoft Graph API. The url I am using for the request is:

https://graph.microsoft.com/beta/me/messages?$filter=toRecipients/any(r: r/emailAddress/address eq '[Email Address]')

But I am getting this is the response:

{
   "error": {
        "code": "ErrorInvalidUrlQueryFilter",
        "message": "The query filter contains one or more invalid nodes.",
        "innerError": {
            "request-id": "7db712c3-e337-49d9-aa8d-4a5d350d8480",
            "date": "2016-09-28T16:58:34"
        }
    }
}

A successful request should look like this (with a lot more data that I have omitted).

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#users('99999999-9999-9999-9999-999999999999')/messages",
    "@odata.nextLink": "https://graph.microsoft.com/beta/me/messages?$skip=10",
    "value": [
        {
            "toRecipients": [
                {
                    "emailAddress": {
                        "name": "[Name]",
                        "address": "[Email Address]"
                    }
                }
            ],
        }
    ]
}

The request works if I remove the filter, and I am able to perform requests with simpler filters.

Is there a problem with my URL, or is there another way to make the request?

解决方案

After several hours looking for the solution, I found in the office365 documentation that the property toRecipients is not filterable:

https://msdn.microsoft.com/en-us/office/office365/api/complex-types-for-mail-contacts-calendar#MessageResource

I guess that it's the same in the graph api. So the only solution is using search.

阅读全文

相关推荐

最新文章