Search code examples
push-notificationgoogle-apigmailgmail-apiwebhooks

Gmail push notification - empty history when Attached file exist


I'm using Gmail push notification in order to get user Gmail activities. It works well but I noticed a weird behavior that prevent me from getting the user sent email attached files

Each time I'm getting a push notification to my server endpoint, I'm sending GET request of user history list using the historyId I received from the raised notification

when sending the history List request on email that sent without a file attachments I'm getting object response that contain the message Id

{"history":[{"id":"59237","messages":[{"id":"15eb563b63b660ed","threadId":"15eb563b63b660ed"}]}],"historyId":"59238"}

but when sending the history List request on email that sent with file attachments I'm not getting the message Id and without it I cant get that message details along with the file attachments

{"historyId":"59281"}

what cause this behavior and what can I do to solve this problem?


Solution

  • it seems I didn't understand the flow of getting user history activities. basically you need to save the HistoryId in the response when registering to webhook and use it to request Users.history: list. the response include the activities info and also historyId that we need to save again - in order to use it next time we get notification about this user activity

    another explanation can be found here