I post here because I'm learning to use Gmail API and I recently encountered a problem. When I try to list unread message with the following code
var request = gapi.client.gmail.users.messages.list({
'userId': 'me',
'labelIds': 'INBOX',
'q': 'is:unread'
});
I sometime get the right messages but sometimes not. It's like gmail api does not have access to the immediate state of gmail and only synchronize every few minutes.
An other example is that when i try to mark a message as read with
var request = gapi.client.gmail.users.messages.modify({
'userId': 'me',
'id': id,
'removeLabelIds': ['UNREAD']
});
request.execute(function (response) {
console.log(response)
}
The response give that the label 'UNREAD doesn't exist for this message (and it is marked as read in Gmail web) but if I refresh my site, it loads the precedent message as unread.
It's driving me crazy because it worked two days ago and now it just not.
Any ideas ?
EDIT
Clearing history between each request is fixing the problem but can't figure why ...
I tried those solutions but none worked Disable gmail api request caching
Try this code: