How to create a draft message in existing thread with gmail API
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)?
python gmail-api
add a comment |
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)?
python gmail-api
add a comment |
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)?
python gmail-api
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)?
python gmail-api
python gmail-api
asked Nov 22 '18 at 12:28
fpghostfpghost
1,01711336
1,01711336
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
As per documentation, a draft can be added to a thread as part of creating, updating, or sending a draft message.
In order to be part of a thread, a message or draft must meet the following criteria:
- The requested
threadId
must be specified on theMessage
or
Draft.Message
you supply with your request.
- The
References
andIn-Reply-To
headers must be set in compliance
with the RFC 2822 standard.
- The
Subject
headers must match.
The documentation also states that in both examples for creating a draft and sending a message, you would simply add a threadId
key paired with a thread ID to a message's metadata, the message
object.
Could you add a code snippet using the python client, since as I mentioned in my post I tried addingthreadId
and for drafts it was simply ignored and the draft was created in a new thread (even though this worked for adding non-draft messages to threads)
– fpghost
Nov 24 '18 at 10:20
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431048%2fhow-to-create-a-draft-message-in-existing-thread-with-gmail-api%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As per documentation, a draft can be added to a thread as part of creating, updating, or sending a draft message.
In order to be part of a thread, a message or draft must meet the following criteria:
- The requested
threadId
must be specified on theMessage
or
Draft.Message
you supply with your request.
- The
References
andIn-Reply-To
headers must be set in compliance
with the RFC 2822 standard.
- The
Subject
headers must match.
The documentation also states that in both examples for creating a draft and sending a message, you would simply add a threadId
key paired with a thread ID to a message's metadata, the message
object.
Could you add a code snippet using the python client, since as I mentioned in my post I tried addingthreadId
and for drafts it was simply ignored and the draft was created in a new thread (even though this worked for adding non-draft messages to threads)
– fpghost
Nov 24 '18 at 10:20
add a comment |
As per documentation, a draft can be added to a thread as part of creating, updating, or sending a draft message.
In order to be part of a thread, a message or draft must meet the following criteria:
- The requested
threadId
must be specified on theMessage
or
Draft.Message
you supply with your request.
- The
References
andIn-Reply-To
headers must be set in compliance
with the RFC 2822 standard.
- The
Subject
headers must match.
The documentation also states that in both examples for creating a draft and sending a message, you would simply add a threadId
key paired with a thread ID to a message's metadata, the message
object.
Could you add a code snippet using the python client, since as I mentioned in my post I tried addingthreadId
and for drafts it was simply ignored and the draft was created in a new thread (even though this worked for adding non-draft messages to threads)
– fpghost
Nov 24 '18 at 10:20
add a comment |
As per documentation, a draft can be added to a thread as part of creating, updating, or sending a draft message.
In order to be part of a thread, a message or draft must meet the following criteria:
- The requested
threadId
must be specified on theMessage
or
Draft.Message
you supply with your request.
- The
References
andIn-Reply-To
headers must be set in compliance
with the RFC 2822 standard.
- The
Subject
headers must match.
The documentation also states that in both examples for creating a draft and sending a message, you would simply add a threadId
key paired with a thread ID to a message's metadata, the message
object.
As per documentation, a draft can be added to a thread as part of creating, updating, or sending a draft message.
In order to be part of a thread, a message or draft must meet the following criteria:
- The requested
threadId
must be specified on theMessage
or
Draft.Message
you supply with your request.
- The
References
andIn-Reply-To
headers must be set in compliance
with the RFC 2822 standard.
- The
Subject
headers must match.
The documentation also states that in both examples for creating a draft and sending a message, you would simply add a threadId
key paired with a thread ID to a message's metadata, the message
object.
answered Nov 23 '18 at 4:07
JacqueJacque
3636
3636
Could you add a code snippet using the python client, since as I mentioned in my post I tried addingthreadId
and for drafts it was simply ignored and the draft was created in a new thread (even though this worked for adding non-draft messages to threads)
– fpghost
Nov 24 '18 at 10:20
add a comment |
Could you add a code snippet using the python client, since as I mentioned in my post I tried addingthreadId
and for drafts it was simply ignored and the draft was created in a new thread (even though this worked for adding non-draft messages to threads)
– fpghost
Nov 24 '18 at 10:20
Could you add a code snippet using the python client, since as I mentioned in my post I tried adding
threadId
and for drafts it was simply ignored and the draft was created in a new thread (even though this worked for adding non-draft messages to threads)– fpghost
Nov 24 '18 at 10:20
Could you add a code snippet using the python client, since as I mentioned in my post I tried adding
threadId
and for drafts it was simply ignored and the draft was created in a new thread (even though this worked for adding non-draft messages to threads)– fpghost
Nov 24 '18 at 10:20
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431048%2fhow-to-create-a-draft-message-in-existing-thread-with-gmail-api%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown