Node js:sendgrid'禁止访问'
我正在使用sendgrid(javascript)将新联系人添加到我的列表中。在市场营销中。
var request = require("request");
var options = { method: 'PUT',
url: '',
headers: { authorization: 'Bearer myapi' },
body: '{"contacts":[{"email": "[email protected]","unique_name":"hello"}]}' };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
但是随后我收到消息“禁止访问”。
我使用的网址错误吗?(API令牌设置为管理员所有访问权限。)
谢谢!
回答如下:看来这里发生了一些事情。
根据docs,Contact API中没有终结点接受方法PUT
。
检查了我们自己的实现之后,您打算执行的操作似乎也有问题。
请参见docs以将多个收件人添加到列表:
POST https://api.sendgrid/v3/contactdb/lists/{list_id}/recipients HTTP/1.1
Request body:
[
"recipient_id1",
"recipient_id2"
]
为了使用该方法,您需要首先create个用户并检索其接收者ID。
POST https://api.sendgrid/v3/contactdb/recipients HTTP/1.1
[
{
"email": "[email protected]",
"unique_name":"hello"
}
]
查看发布的链接以获取有关其用法和响应的更多信息。
Node js:sendgrid'禁止访问'
我正在使用sendgrid(javascript)将新联系人添加到我的列表中。在市场营销中。
var request = require("request");
var options = { method: 'PUT',
url: '',
headers: { authorization: 'Bearer myapi' },
body: '{"contacts":[{"email": "[email protected]","unique_name":"hello"}]}' };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
但是随后我收到消息“禁止访问”。
我使用的网址错误吗?(API令牌设置为管理员所有访问权限。)
谢谢!
回答如下:看来这里发生了一些事情。
根据docs,Contact API中没有终结点接受方法PUT
。
检查了我们自己的实现之后,您打算执行的操作似乎也有问题。
请参见docs以将多个收件人添加到列表:
POST https://api.sendgrid/v3/contactdb/lists/{list_id}/recipients HTTP/1.1
Request body:
[
"recipient_id1",
"recipient_id2"
]
为了使用该方法,您需要首先create个用户并检索其接收者ID。
POST https://api.sendgrid/v3/contactdb/recipients HTTP/1.1
[
{
"email": "[email protected]",
"unique_name":"hello"
}
]
查看发布的链接以获取有关其用法和响应的更多信息。