使用curl命令向sendgrid添加电子邮件地址

Adding email addresses to sendgrid with curl command

本文关键字:添加 电子邮件地址 sendgrid curl 命令 使用      更新时间:2024-05-03

将电子邮件添加到sendgrid营销列表需要什么curl命令?我查阅了文档,很难理解实际的curl命令是什么,因为授权部分和实际的api端点是分开的。我试过:

curl -X "POST" "https://api.sendgrid.com/v3/contactdb/recipients" -H "Authorization: Bearer YOURUSERPASSWORDSTRING" -H "Content-Type: application/json" -d '{"list":"Beta List", "email":"bla@bla.com", "name":""}'

即使我添加了一个伪名称,并且YOURUSERPASSWORDSTRING是通过在终端中调用以下内容来确定的,它似乎仍然会给我带来问题:

echo -n "user:password'!" | openssl base64

我错过了什么?还有,使用javascript/Meter.js有更好的方法吗?谢谢

cURL通过--user-u标志支持基本身份验证,并将处理base64编码和添加身份验证标头。

尝试

curl -X "POST" "https://api.sendgrid.com/v3/contactdb/recipients" -u username:password -H "Content-Type: application/json" -d '{"list":"Beta List", "email":"bla@bla.com", "name":""}'

关于更多信息,这里有一个来自SendGridWebneneneba API auth-docs的示例。