Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Error no label add or removes specified" when trying to modify labels using Gmail's Node.js API

I'm trying to modify the labels of emails in my inbox using gmail's Node.js API. My function to mark an email as read and star it is:

function markAsRead(auth, req, res)
{
    var gmail = google.gmail('v1');
    console.log(req.body.id);
    gmail.users.messages.modify({
        auth: auth,
        id: req.body.id,
        userId: 'me',
        resouce:
            {
                "addLabelIds": [
                    "STARRED"
                ],
                "removeLabelIds": [
                    "UNREAD"
                ]
            }

    }, function(err, response) {
        if (err) 
        {
            console.log('...The API returned an error: ' + err);
            return;
        }
        console.log("Success???");
    });
}

It gives an error saying No label add or removes specified. I've checked the email objects coming in and in their labelIds attributes "UNREAD" and "STARRED" appear so they're valid labelIds. I seem to be doing what the docs for the API say is correct but it keeps giving that same error.

like image 306
David Avatar asked Feb 15 '26 12:02

David


1 Answers

It looks good. I think it's just a typo. resouce should be resource.

like image 79
Tholle Avatar answered Feb 18 '26 02:02

Tholle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!