gpt4 book ai didi

node.js -/v3/contactdb/收件人的SendGrid 403响应-所需权限

转载 作者:行者123 更新时间:2023-12-03 09:58:09 27 4
gpt4 key购买 nike

我需要什么权限,或者此SendGrid API调用出错了?

我正在尝试将新的收件人(/contactdb/recipients)发布到“发送网格”,但始终收到403响应:

即使从SendGrid Explorer调用API,我也能得到它

联系人API-收件人

  • POST->添加收件人
  • {
    "errors": [
    {
    "field": null,
    "message": "access forbidden"
    }
    ]
    }

    这使我认为我的API key 没有足够的权限,但具有完全访问权限。

    这也是我的客户代码。
    require("dotenv").config();
    const client = require("@sendgrid/client");

    exports.handler = function(event, context, callback) {
    const body = JSON.parse(event.body);
    const email = body.email;

    if (!process.env.SENDGRID_API_KEY) {
    callback("No API Key");
    }

    client.setApiKey(process.env.SENDGRID_API_KEY);
    const request = {
    method: "POST",
    url: "/v3/contactdb/recipients",
    body: JSON.stringify([{ email }])
    };

    client
    .request(request)
    .then(([response, body]) => {
    // console.log(response.statusCode);
    // console.log(body);
    callback(null, response, body);
    })
    .catch(error => {
    // console.log(JSON.stringify(error.response.body.errors));
    callback(error);
    });

    };

    最佳答案

    每个支持:

    We have just very recently released a "New Marketing Campaigns" experience and the endpoints have changed from our "Legacy Marketing Campaigns".

    Try this endpoint:

    https://api.sendgrid.com/v3/marketing/contacts

    I pulled it from our documentation here:

    https://sendgrid.api-docs.io/v3.0/contacts/add-or-update-a-contact

    关于node.js -/v3/contactdb/收件人的SendGrid 403响应-所需权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56945838/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com