Gmail API does not return valid emails compared to the Gmail web interface for date requests

The results are different from the Gmail api and Gmail web ui when using the standard request format, as described here - https://support.google.com/mail/answer/7190 .

The problem is with the after / before and newer / old options. For example, the following Gmail api request "after: 2015/11/19 to: 2015/11/20" returns different results compared to running the same request on the Gmail website. The web interface looks correct, while api returns emails from the next day (20). Perhaps a time zone problem?

Check past questions. I see something similar here how to use the GMAIL API request filter for datetime (the server processes requests as PST time). If so, it might be worth updating the documents or thinking about a possible solution.

Steps to reproduce the problem.

  • Have mail in your gmail account covering the dates below. Inc a few days after that.
  • Run after: 2015/11/19 to: 2015/11/20 on the Gmail website.
  • Request a Gmail api with "after: 2015/11/19 to: 2015/11/20" for the q parameter using https://developers.google.com/gmail/api/v1/reference/users/messages/list
  • Compare the results. (I had differences in following these steps regarding a UK Gmail account).

You should only see emails from the 19th, but I see messages from the 19th and 20th when you use the api. The ui network works as expected and only returns messages from the 19th.

FYI: I also used other request parameters, such as "from: example@example.com " in conjunction with the before / after or newer / old parameters. I wanted to simplify the report / bug question.

Also: The api requests I made with the node module called node -gmail-api. Verifying the code of the endpoint used is the message code:

body: 'GET ' + api + '/gmail/v1/users/me/messages/' + m.id + fields + '\n' 

Is the problem caused by "messages" and not the "message / list" endpoint? How is the answer to this question? - Why does a search in the gmail API return a different result than a search on the gmail website?

Is this a bug / feature? Is there a solution like using epoch ms. (also not in the docs as I see)

thanks

+5
source share
1 answer

You can list messages with second precision if you want:

 q = after:<start_of_day_in_seconds> AND before:<end_of_day_in_seconds> 

So, for example, from Wed, 25 Nov 2015 00:00:00 GMT to Wed, 25 Nov 2015 23:59:59 GMT :

 q = after:1448409600 AND before:1448495999 
+6
source

Source: https://habr.com/ru/post/1236782/


All Articles