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.
It looks good. I think it's just a typo. resouce should be resource.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With