简体   繁体   English

使用 OData $filter 通过 flagStatus 获取 Microsoft Graph 消息

[英]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获取消息

  1. flag is null flagnull
  2. or flag/flagStatus is nullflag/flagStatusnull
  3. or 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.

相关问题 Microsoft Graph API - Odata 筛选器 - Microsoft Graph API - Odata Filter Microsoft Graph API odata $filter 查询似乎不起作用 - Microsoft Graph API odata $filter query does not appear to work 使用OData过滤guid(Microsoft Graph) - Filtering on guid using OData (Microsoft Graph) 使用Microsoft Data Flow通过OData筛选器查询从Sharepoint列表中获取过期日期的未清项目 - Using OData Filter Query to get open items with past due date from Sharepoint list using Microsoft Flow 微软图形 API 使用过滤器获取共享点项目 - microsoft graph API using filter on get sharepoint items 如何使用oData查询从Azure图形API过滤结果 - how to filter result from azure graph API using oData query 在Microsoft Graph API和ODATA上通过电子邮件搜索用户时,使用句点/点不返回任何结果 - Using period / dot when searching users by email on Microsoft Graph API and ODATA return no results API GET 调用 R 使用来自 OData 的过滤器 - API GET call in R using filter from OData 从Microsoft Graph统一OData端点获取一些数据 - Getting some data from Microsoft Graph unified OData endpoint Microsoft Graph API 元数据是否确认 OData 协议规范? - Does the Microsoft Graph API metadata confirm the OData Protocol specification?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM