按ID过滤消息需要授权

问题描述 投票:0回答:1

我正在尝试使用 sendgrid api 来根据 ID 过滤消息。我有以下代码:

try {
    client.setApiKey(process.env.SendGridKey);

    const request = {
      url: `/v3/messages/${req.params.mail_id}`,
      method: "GET",
    };

    await client
      .request(request)
      .then(([response, body]) => {
        context.res = {
          body,
        };
      })
      .catch((error) => {
        console.log(JSON.stringify(error));
      });
  } catch (error) {
    context.res = {
      status: 500,
    };
  }

我收到 400 错误提示:

[{"message":"authorization required"}]

API 密钥正确,正在使用中。我还有其他这样写的方法,它们似乎都运行良好。

这里可能是什么问题?我使用的代码与 sendgrid API 参考中的大部分相同。

node.js sendgrid sendgrid-templates
1个回答
0
投票

嘿,确保您订阅了“扩展的电子邮件活动历史记录”插件。它使您可以访问到 api 端点: see this link

© www.soinside.com 2019 - 2024. All rights reserved.