I created a label, "handler_gmail", in Gmail's web interface via the typical approach.
When I try to set that label for a message via the Gmail API (Python client library), I get the response HttpError 400, returned "Invalid label: handler_gmail".
I am sure the label exists (I've checked multiple times – no typos).
I am trying to set it like so:
gs.users().messages().modify(userId=username, id=m['id'], body={"addLabelIds": ['handler_gmail']}).execute()
I tried adding a "removeLabelIds": [] key/value pair to the dictionary (thinking maybe it was required), but got the same "Invalid label" error.
Any help with this is greatly appreciated! So close to being able to do what I need to with this project!
I was able to list the system and user labels via print(gs.users().labels().list(userId=username).execute())
This revealed that the label ID for my label was something else ("Label_1" -- the name was "handler_gmail"). So I will make a support method that gets me a label ID by name, and add the label to the message (via modify) using the ID.
Thanks!
Gmail API: "Invalid Label" When Trying to Set Message Label to One That I Created