如何使用Graph API获取对话中的邮件线程
我正在用Power Automate构建一个AI邮件起草代理。
我打算通过HTTP操作,使用conversationID来获取线程邮件,使用GraphAPI。
https://graph.microsoft.com/v1.0/users/@{items('Apply_to_each_Email_Box')}/messages?$filter=conversationId%20eq%20'@{items('Apply_to_each_Email')['conversationId']}'&$top=5&$orderby=receivedDateTime%20desc&$select=id,subject,body,sender,from,toRecipients,ccRecipients,receivedDateTime,isRead
这是我当前的GraphAPI URL,但现在我收到 "Bad Request" 错误。
我想问的是:
1. GraphAPI是否支持按conversationID过滤?
2.如果是,以上URL存在的问题是什么?
3.如果不是,是否有替代方法?
注: 所有变量都严格按原样应用。
解决方案
你需要确保在conversationId过滤中对所使用的base64值进行转义,例如
https://graph.microsoft.com/v1.0/me/messages?$filter=conversationId%20eq%20'AAQkADkwNWI2MTliLWE1ZWUtNDhhNC04NmFjLWFhOWNkZGVmZTFjZQAQAPdaF5Iy54dDklX8GcV8s-M%3D'
来自该项的原始base64值不起作用
备选方案
问题在于,一旦你在 $orderBy 中指定了 receivedDateTime,你还必须在 $filter 中指定 receivedDateTime,但要在任何其他属性之前,例如
...$filter=receivedDateTime ge 1900-01-01 and conversationId%20eq%20'@{items('Apply_to_each_Email')['conversationId']}'...
https://graph.microsoft.com/v1.0/users/@{items('Apply_to_each_Email_Box')}/messages?$filter=receivedDateTime ge 1900-01-01 and conversationId%20eq%20'@{items('Apply_to_each_Email')['conversationId']}'&$top=5&$orderby=receivedDateTime%20desc&$select=id,subject,body,sender,from,toRecipients,ccRecipients,receivedDateTime,isRead
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。