c# - 如何按 conversationId 过滤消息
问题描述
我正在尝试获取属于对话的消息列表。
var conversationMessages = await client.Me.Messages
.Request()
.Filter($"startsWith(conversationId, '{message.ConversationId}')")
.Select(m => new { m.ConversationId })
.GetAsync().ConfigureAwait(false);
这给出了错误消息
包含过滤器只能用于字符串属性。
我不明白这个错误信息,因为 conversationId 是一个字符串。
根据另一个问题的答案,我认为startsWith
用equals
or替换eq
可能会起作用。这会更好,因为我要检查的是平等。但后来我得到
过滤子句无效
表示equals
尚不支持。
解决方案
我已经在Graph Explore中对其进行了测试,它对我来说效果很好。我已经给出了 HTTP 调用 -https://graph.microsoft.com/v1.0/me/messages?$filter=conversationId eq 'AAQkAGI0Mjk2NTQ5LTE4MjctNDE1Yy04Nzc0LWIxNzA0MDBkNDkwZAAQADdMKw2knP9Pj1rq9BpHpsc='
所以试试下面的代码。
var conversationMessages = await client.Me.Messages
.Request()
.Filter("conversationId eq 'messageConverstaionid'")
.GetAsync();
推荐阅读
- c# - 从完整的文本字符串中获取用户名
- powershell - 如何在我的 Web 应用程序中生成访问令牌以与 Exchange Online Powershell 模块一起使用?
- python - 如何以及在哪里获取 json 和 pem 文件以远程连接到内核?
- python - 检查Python DataFrame中的任何值是否为0
- android - 保存和多次更新firebase
- javascript - 从 reducer 中的 store 中读取 state
- c# - AWS lambda 无法访问共享文件夹?
- php - Firebase 索引.php
- amazon-web-services - AWS CodePipeline 错误“当前正在进行对此更改集的操作。请稍后再试此操作”
- firefox - 如何在 Firefox 中截取屏幕质量的屏幕截图?