GMail API errors: not found (404) when calling to get drafts using drafts.get from ids provided by drafts.list

It's quite common in the Gmail API that drafts.list returns the project id but when I pass it to drafts.get it returns a 404 error. This is repeatable for some projects ids, I can call drafts.list again and they are still there and I can then call drafts.get and get the same error again. I can also call messages.get with the specified message id and get the response as expected and I can see the draft in the gmail client.

This seems to be a bug in the GMail API. Any ideas for workarounds? And does anyone know the correct way to report bugs to google?

+3


source to share


2 answers


I get the same problem, here's how to reproduce:

1) Start composing a new message in the Gmail web client. Do not add anything to the To or Body field. Then close the message to save it as a draft.

2) Extract the list of streams with the following code:

threads = gmail_client.users().threads().list(userId='me', maxResults=15, pageToken=pageToken, q='-in:(chats OR draft) in:all').execute()

      



4) Then, extract each of these streams in a batch request:

batch.add(gmail_client.users().threads().get(userId='me', id=thread['id'], format='metadata', metadataHeaders=['subject','date','to','from']), callback=threadCallback)

      

The returned error is:

https://www.googleapis.com/gmail/v1/users/me/threads/154e44a4c80ec7e4?format=metadata&metadataHeaders=subject&metadataHeaders=date&metadataHeaders=to&metadataHeaders=from&alt=json> returned "Not found

+1


source


To use drafts.get, you must use an immutable project ID, not a project post ID, which will change after every update in the draft. Drafts.list provides both an immutable ID and a message ID for draft messages.



0


source







All Articles