我正在尝试在创建联系人时(使用他们的官方C#包装器(填充SendInBlue的FIRSTNAME
属性。
但它一直显示这个异常:
{"调用CreateContact时出错:{\"code\":\"invalid_parameter\",\"message\":"attributes should be a object"}
我的代码:
Configuration.Default.ApiKey.Add("api-key", "XXXX");
var apiInstance = new ContactsApi();
var apiAttributes = new AttributesApi();
var createContact = new CreateContact
{
Email = email,
Attributes = "{"FIRSTNAME":"Matt"}"
};
try
{
CreateUpdateContactModel result = apiInstance.CreateContact(createContact);
}
catch (ApiException ex)
{
}
我尝试了很多不同的方法,现在已经失败了24个多小时,所以我想问StackOverflow。有人知道我做错了什么吗?
您可以创建一个Json对象并将其传递给New CreateContact,如
JObject attrib = JObject.FromObject(new
{
FIRSTNAME = "Matt",
LASTNAME = "Matt last name"
});
var createContact = new CreateContact
{
Email = "matt@email.com",
Attributes= attrib
};