2

I'm trying to populate the FIRSTNAME attribute for SendInBlue when creating a contact (using their official C# wrapper).

But it keeps displaying this exception:

{"Error calling CreateContact: {\"code\":\"invalid_parameter\",\"message\":\"attributes should be an object\"}"}

My code:

    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)
    {

    }

I've tried so many different methods, it's now been over 24 hours of failing so I thought I'd ask StackOverflow. Does anybody know what I'm doing wrong?

MattHodson
  • 736
  • 7
  • 22

1 Answers1

1

You can create a Json object and pass it to the New CreateContact like this

JObject attrib = JObject.FromObject(new
            {
                    FIRSTNAME = "Matt",
                    LASTNAME = "Matt last name"
            });

            var createContact = new CreateContact
            {

                Email = "matt@email.com",
                Attributes= attrib
            };