The results differ between the Gmail api and Gmail web ui when using the standard query format as described here - https://support.google.com/mail/answer/7190.
The issue is specifically for the parameters after/before and newer/older. For example the following Gmail api query "after:2015/11/19 before:2015/11/20" returns different results compared with running that same query in the Gmail web ui. The web ui looks correct whereas the api returns emails from the next day (20th). Possibly a timezone conversation problem?
Checking past questions I see something similiar here how to use GMAIL API query filter for datetime (the server processes the queries as PST time). If this is the case it might be worth updating the docs or think about a possible solution.
Steps to reproduce the problem.
Should only see emails from the 19th, but I see emails dated the 19th AND 20th when using the api. The web ui works as expected and only returns emails dated the 19th.
FYI: I was also using other query parameters such as "from: [email protected]" in conjuction with before/after or newer/older params. I wanted to simplify the bug report / question.
Also: The api queries I was making with a node module called node-gmail-api. Checking the code the endpoint being used is 'messages' code:
body: 'GET ' + api + '/gmail/v1/users/me/messages/' + m.id + fields + '\n'
Is the problem that 'messages' and not 'messages/list' endpoint is being called? As per answer to this question? - Why does search in gmail API return different result than search in gmail website?
Is this a bug / feature? Is there a workaround such as using epoch ms. (also not in the docs as I can see)
Thanks
The Gmail API is a RESTful API that can be used to access Gmail mailboxes and send mail. For most web applications the Gmail API is the best choice for authorized access to a user's Gmail data and is suitable for various applications, such as: Read-only mail extraction, indexing, and backup.
You can list the messages with second accuracy if you would like:
q = after:<start_of_day_in_seconds> AND before:<end_of_day_in_seconds>
So e.g. from Wed, 25 Nov 2015 00:00:00 GMT
to Wed, 25 Nov 2015 23:59:59 GMT
would be:
q = after:1448409600 AND before:1448495999
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With