joao santana
joao santana

Reputation: 29

HTTPERROR 400 Removing a message label gmail api python

I'm using this slice of code to try to remove the label "INBOX" from a message, but i'm getting error "no label to remove or specify"

message = service.users().messages().modify(userId='me', id=id, body='INBOX').execute();

Upvotes: 0

Views: 815

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116968

I think your body is wrong the body is a json object probably something like this

msg_labels =  {'removeLabelIds': ['INBOX'], 'addLabelIds': []}

message = service.users().messages().modify(userId=user_id, id=msg_id,
                                             body=msg_labels).execute()

You might want to check the documented example my python is very basic messages.modify python

Upvotes: 1

Related Questions