It seems like there may be a serious issue in the Gmail REST API.
- Call /userId/messages to obtain a list of message
- For each, call /userId/messages/id to get the message
- Obtain the highest (or any) startHistoryId on each message object
- Then call /userId/history/list passing startHistoryId as a parameter
The result is unexpected. The Gmail REST API is returning 404 Not Found.. It seems the returned historyId is not registered or valid.
On calling /userId/profile, the startHistoryId is valid and can be used successfully in the /userId/history/list call.
com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
{
"code" : 404,
"errors" : [ {
"domain" : "global",
"message" : "Not Found",
"reason" : "notFound"
} ],
"message" : "Not Found"
}