2016-07-07 30 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

謝謝你的見解。 –

相關問題