我想在我的网站上使用 SendinBlue API,但我面临两个问题。我想从电子邮件中创建一个新联系人并将这个新联系人添加到 SendinBlue 网站上的联系人列表中。为了做到这一点,我正在关注此页面https://developers.sendinblue.com/reference/createcontact
第一个问题: 当我尝试执行代码时,出现一个错误,告诉我密钥已经在这一行的字典中(我显然用 v3 API 密钥替换了“YOUR API KEY”):
Configuration.Default.ApiKey.Add("api-key", "YOUR API KEY");
第二个问题: 之后,当我将新创建的联系人添加到 API 时,我在这一行有一个错误,告诉我“发生了一个或多个错误”:
CreateUpdateContactModel result = apiInstance.CreateContact(createContact);
这是我的代码:
// I replaced "YOUR API KEY" with my private api key
sib_api_v3_sdk.Client.Configuration.Default.ApiKey.Add("api-key", "YOUR API KEY");
var apiInstance = new ContactsApi();
JObject attributes = new JObject();
List<long?> listIds = new List<long?>();
listIds.Add(2);
bool emailBlacklisted = false;
bool smsBlacklisted = false;
bool updateEnable = true;
List<string> smtpBlacklistSender = new List<string>();
try
{
var createContact = new CreateContact(email, attributes, emailBlacklisted,
smsBlacklisted, listIds, updateEnable, smtpBlacklistSender);
CreateUpdateContactModel result = apiInstance.CreateContact(createContact);
Debug.WriteLine(result.ToJson());
Console.WriteLine(result.ToJson());
Console.ReadLine();
}
catch (Exception exc)
{
Debug.WriteLine(exc.Message);
Console.WriteLine(exc.Message);
Console.ReadLine();
}
有没有人已经面临这个问题之一?
谢谢