[英]Get Microsoft Graph messages by flagStatus using OData $filter
I'm writing Microsoft Graph OData query to get mail messages based on message flagStatus in order to reuse working query in my C# code.我正在编写 Microsoft Graph OData 查询以获取基于消息 flagStatus 的邮件消息,以便在我的 C# 代码中重用工作查询。 How correct query should look like?
正确的查询应该是什么样的?
Following example is tried in Graph Explorer 's sample account where all messages have object flag
with field flagStatus = "notFlagged"
.以下示例在Graph Explorer的示例帐户中进行了尝试,其中所有消息都具有带有字段
flagStatus = "notFlagged"
对象flag
。
https://graph.microsoft.com/v1.0/me/messages?$filter=flag/flagStatus eq 'notFlagged'
It is expected that all messages should be returned.预计应返回所有消息。 But as a result empty array was given back.
但结果是返回了空数组。
If in query I change eq
to ne
to be如果在查询中我将
eq
更改为ne
为
https://graph.microsoft.com/v1.0/me/messages?$filter=flag/flagStatus ne 'notFlagged'
then all messages are returned.然后返回所有消息。 But by me it is expected that here should be empty array in this case.
但是我预计在这种情况下这里应该是空数组。
Considering that maybe flag
object isn't ready for filtering, I also tried to $expand
it考虑到
flag
对象可能还没有准备好过滤,我也尝试$expand
它
https://graph.microsoft.com/v1.0/me/messages?$expand=flag&$filter=flag/flagStatus eq 'notFlagged'
but got error message但收到错误信息
Property 'flag' on type 'microsoft.graph.message' is not a navigation property or complex property.
类型“microsoft.graph.message”上的属性“标志”不是导航属性或复杂属性。 Only navigation properties can be expanded.
只能扩展导航属性。
So probably $expand
for flag filtering is not needed.所以可能不需要
$expand
进行标志过滤。 But is it possible to filter by message's flag at all?但是是否可以通过消息的标志进行过滤?
Also if consider situation that flag
object could be null and also flagStatus
inside could be null (at least in C# class Microsoft.Graph.FollowupFlag
property FlagStatus
is nullable), then how query should look like to meet full requrirement below?另外,如果考虑
flag
对象可能为空并且内部的flagStatus
可能为空的情况(至少在 C# 类Microsoft.Graph.FollowupFlag
属性FlagStatus
是可为空的),那么查询应该如何满足下面的完整要求?
Get messages whose获取消息
flag
is null
flag
为null
flag/flagStatus
is null
flag/flagStatus
为null
flag/flagStatus
is 'notFlagged'
flag/flagStatus
是'notFlagged'
I had the same problem, probably is nullable as suggested.我有同样的问题,可能按照建议可以为空。 There's only three possible statuses according to the followupFlag documentation , so I worked around it with a not equal and condition for the two other statuses, complete and flagged.
根据followupFlag 文档,只有三种可能的状态,所以我使用不相等和条件解决了其他两个状态,完成和标记。
https://graph.microsoft.com/v1.0/me/messages?$filter=flag/flagStatus ne 'flagged' and flag/flagStatus ne 'complete'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.