Get all messages from Outlook API

▼魔方 西西 提交于 2019-12-24 08:35:29

问题


I'm consuming the Outlook API, attempting to access all messages from an inbox which contains ~45,000 messages (and other folders such as Sent Items).

The main request I'm making is to https://outlook.office.com/api/v2.0/me/messages. If I add ?$count=true, the "@odata.count" value is returned as -1.

I can add $top=500 to the request which gives me 500 messages returned and an "@odata.nextLink", but if I pass $top=5000, there's no "@odata.nextLink" which I'd expect to see.

A few particular questions here if anyone can help:

  1. Is this the best way to try and get all the messages out of all folders?
  2. Is there a reason count would be returning -1, and is there a way to get an accurate figure of the number of messages returned?
  3. Is there a maximum $top size I need to pass to get a valid request back?

回答1:


  1. Yes, but understand it includes Drafts, Deleted Items, and Sent Items in addition to all of the other mail folders.
  2. This is a known issue with /me/messages. Basically the way that /me/messages gives all messages across all folders is by using a search folder, which dynamically updates. The API doesn't report accurate counts for search folders (usually just returns -1).
  3. The highest $top should be 1000.


来源:https://stackoverflow.com/questions/47782180/get-all-messages-from-outlook-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!