2016-07-07 76 views
0

给出一个Id(又名ItemIds)列表,我们如何通过OutlookREST Api有效检索电子邮件?使用Id和Outlook REST API检索邮件

我试图伪造以下请求。

https://outlook.office365.com/api/beta/me/MailFolders/<somefolderId>/messages?$filter=((Id eq 'firstId') or (Id eq 'secondId') or (Id eq 'thirdId')) 

但是我收到了BadRequest 400错误:“属性'Id'不支持筛选”这非常清楚。

作为一种解决方法,我使用InternetMessageId(我不在乎电子邮件的哪个“副本”被返回)。有没有一种方法可以使用Id来获得更好的性能?

回答

1

您可以对batch request中的每个ID做最多20个个人GET请求。这仅在beta终端上可用。

喜欢的东西:

POST https://outlook.office.com/api/beta/$batch HTTP/1.1 

Authorization: Bearer aGFwcHlnQGRr== 
Host: outlook.office.com 
Content-Type: multipart/mixed; boundary=batch_myBatchId 


--batch_myBatchId 
Content-Type: application/http 
Content-Transfer-Encoding: binary 

GET /api/beta/me/messages/{id1} HTTP/1.1 


--batch_myBatchId 
Content-Type: application/http 
Content-Transfer-Encoding: binary 

GET /api/beta/me/messages/{id2} HTTP/1.1 


--batch_myBatchId-- 
+0

非常感谢你。知道在beta终端中,InternetMessageId是Message对象的主要属性。据你所知,在ItemId上执行20个项目的批量请求要比在'InternetMessageId'上执行20个'或'语句的$ filter快得多? –

+1

我没有任何硬性数据,但总的来说,我会避免这样的过于复杂的过滤器。我认为用Ids获取会更快。 –

+0

谢谢你的见解。 –

相关问题