如何使用Microsoft Graph Node.js SDK获取邮件线程?Filter语句报错求助
解决Microsoft Graph Mail API筛选邮件线程的无效过滤子句问题
你的代码触发"Invalid filter clause"错误,核心原因是**conversationId属于字符串类型,Graph API要求过滤条件里的字符串值必须用单引号包裹**,你之前的代码直接拼接变量,没有加单引号,导致语法不合法。
修正后的代码:
const messages3 = await client.api('/me/mailFolders/Inbox/messages').filter(`conversationId eq '${threadId}'`).get();
额外提醒:如果你的threadId本身包含单引号字符,需要先转义(把单个单引号替换成两个单引号),避免再次触发语法错误,示例代码:
const escapedThreadId = threadId.replace(/'/g, "''"); const messages3 = await client.api('/me/mailFolders/Inbox/messages').filter(`conversationId eq '${escapedThreadId}'`).get();
内容的提问来源于stack exchange,提问作者sean-11x
相关产品推荐
相关产品推荐

