While sending an email using the /users.messages/send API, is it possible to assign the message with a label in the same API call?
I'm aware you can use modify to apply a label to the message but I cannot include the gmail.modify scope for this application so using that endpoint isn't an option for me. The documentation says that the send endpoint takes an instance of Message, which allows for a labelIds key.
I've tried making the API request with the JSON body below. It successfully sends the email but it does not assign the label. Since the email is sent, I'm confident the raw message is not the issue. I suspect this endpoint is just ignoring the labelIds part of the body instead.
Does anyone know if it's possible to set the label while using the send endpoint?
{
"raw": "<RFC 2822 formatted and base64url encoded string>",
"labelIds": [
"Label_1"
]
}
I obtained the ID, Label_1, from the labels endpoint directly so the ID is correct.
These are the scopes that my client + user are approved to use. That being said, I also included extra scopes to test but the same issue occurs, the labels aren't set even if you have gmail.modify and gmail.compose scopes approved.
userinfo.email
userinfo.profile
https://www.googleapis.com/auth/gmail.labels
https://www.googleapis.com/auth/gmail.send
https://www.googleapis.com/auth/contacts.readonly
Edit: In case this is a bug, I filed a ticket with Google as well.