Using the python google client I able to create new messages within an existing thread with id threadId
as follows:
message = (service.users().messages().send(userId='me', body={'threadId': <threadId>}, media_body=message['media_body'])
.execute())
(here I'm using media_body as it supports the /upload
endpoint for large attachments)
This works fine for messages, and the threadId
optional parameter is documented at https://developers.google.com/gmail/api/v1/reference/users/messages/send
However I have been unsuccessful doing the same when creating new draft messages, and don't see any docs about it at https://developers.google.com/gmail/api/v1/reference/users/drafts/create
I tried adding threadId
to the draft body when doing draft = service.users().drafts().create(userId=user_id, body={'threadId': <threadId>}, media_body=message_body['media_body']).execute()
at the create draft stage and it simply is ignored.
I also tried adding threadId
to the body at the send draft stage: message = service.users().drafts().send( userId='me', body={'id': draft_id, threadId': <threadId>}).execute()
and this was also ignored.
Either way the draft message just gets created in its own, new thread.
How can I create a new draft message within an existing thread with the gmail API (and specifically with Python client)?