尝试使用 Gmail 的 Node.js API 修改标签时出现“未添加或删除标签错误”

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

本文关键字:标签 添加 错误 删除 Gmail Node 修改 API js      更新时间:2023-09-26

我正在尝试使用gmail的Node.js API修改收件箱中电子邮件的标签。我将电子邮件标记为已读并为其加星标的功能是:

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???");
    });
}

它给出一个错误,指出指定无标签添加或删除。我已经检查了传入的电子邮件对象,并在它们的标签ID属性中出现了"未读"和"星标",因此它们是有效的标签ID。我似乎正在做 API 的文档所说的是正确的,但它一直给出同样的错误。

看起来不错。我认为这只是一个错字。 resouce应该是resource.