Gmail REST API get message function returns invalid historyId -


it seems there may serious issue in gmail rest api.

  1. call /userid/messages obtain list of message
  2. for each, call /userid/messages/id message
  3. obtain highest (or any) starthistoryid on each message object
  4. then call /userid/history/list passing starthistoryid parameter

the result unexpected. gmail rest api returning 404 not found.. seems returned historyid not registered or valid.

on calling /userid/profile, starthistoryid valid , can used in /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" } 

this not bug in api , documented @ https://developers.google.com/gmail/api/v1/reference/users/history/list

specifically "history ids increase chronologically not contiguous random gaps in between valid ids. supplying invalid or out of date starthistoryid typically returns http 404 error code. historyid typically valid @ least week, in circumstances may valid few hours. if receive http 404 error response, application should perform full sync."

so using historyid outside range of history stored (it's not stored indefinitely, expensive). it's stored long enough syncing clients need (e.g. week or so).

if need sync point forward use historyid returned getprofile. historyid on message when message last updated, months or years ago, longer history stored.

see sync'ing guide: https://developers.google.com/gmail/api/guides/sync


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -