$过滤所有没有“类别”的邮件

问题描述 投票:0回答:2

我尝试使用 Microsoft Graph Node.JS API 检索所有没有“类别”(“类别”是字符串集合)的邮件。

我可以检索类别为“xyz”的邮件,但反之则不行。

此代码成功检索所有具有“xyz”类别的邮件:

   .api("/users('[email protected]')/mailfolders/inbox/messages")
   .top(10)
   .select('subject,from,receivedDateTime')
   .filter("categories/any(t:t eq 'xyz')")
   .orderby('receivedDateTime DESC')
   .get();

当我尝试时:

.filter("categories/any(t:t ne 'xyz')")
我收到所有邮件(有或没有“类别”'xyz')

当我尝试时:

.filter("not categories/any(t:t eq 'xyz')")
我收到错误消息
{"code": "BadRequest","message":"Filter not supported."}

当我尝试时:

.filter("categories/all(t:t ne 'xyz')")
我收到错误消息
{"code": "BadRequest","message":"Filter not supported."}

node.js sdk microsoft-graph-api
2个回答
1
投票

你成功解决这个问题了吗?我猜你尝试的 3 个选项中的 2 个是可以解释的:

  1. .filter("categories/any(t:t ne 'xyz')")
    这将返回已分配与“xyz”不同的任何类别或未分配任何类别的邮件。
  2. .filter("not categories/any(t:t eq 'xyz')")
    我没能让过滤器与 not 关键字一起工作
  3. .filter("categories/all(t:t ne 'xyz')")
    据我所知,MS Graph API 不支持“all”关键字

1
投票

如果有人仍在寻找答案,我想我找到了。

否定运算符对我有用:

NOT(categories/any())

   .api("/users('[email protected]')/mailfolders/inbox/messages")
   .top(10)
   .select('subject,from,receivedDateTime')
   .filter("NOT(categories/any())")
   .orderby('receivedDateTime DESC')
   .get();
© www.soinside.com 2019 - 2024. All rights reserved.