3

I'm using MailChimp.Net.V3 and I would like to know how to send an address to MailChimp API. I'm using C# and ASP.NET.

I've followed instructions from MailChimp.Net.V3 on adding a new contact with merge fields: https://github.com/brandonseydel/MailChimp.Net

See example code from MailChimp GitHub page. It doesn't show how to send the address via the merge fields.

var listId = "TestListId";

// Use the Status property if updating an existing member
var member = new Member { EmailAddress = $"githubTestAccount@test.com", StatusIfNew = Status.Subscribed };
member.MergeFields.Add("FNAME", "HOLY");
member.MergeFields.Add("LNAME", "COW");
await this.mailChimpManager.Members.AddOrUpdateAsync(listId, member);

I know from the MailChimp documentation that those Address fields exist. From the API documentation, the Address is an object type. https://mailchimp.com/developer/marketing/docs/merge-fields/

  • addr1
  • addr2
  • city
  • country
  • state
  • zip

I've tried plain text and JSON format. This is what I've tried.

member.MergeFields.Add("ADDRESS", "123 Freddie Ave");

member.MergeFields.Add("ADDRESS", "{ addr1: \"123 Freddie Ave\",city: \"Atlanta\",state: \"GA\",zip: \"12345\"}");

member.MergeFields.Add("ADDR1", "123 Freddie Ave");

member.MergeFields.Add("ADDRESS:ADDR1", "123 Freddie Ave");

member.MergeFields.Add("CITY", "Atlanta");

Every time I send a contact to the API via MailChimp.Net.V3, the Address field is blank.

Can you please help me to find the correct format for sending an address?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
jova85
  • 317
  • 2
  • 10

1 Answers1

0

Actually, the JSON string you tried was formatted incorrectly

According to this

this should work:

member.MergeFields.Add("ADDRESS","{\"addr1\":\"123 Freddie Ave\",\"addr2\":\"secondline\",\"city\":\"Atlanta\",\"state\":\"GA\",\"zip\":\"12345\",\"country\":\"USA\"}");
J.Salas
  • 1,268
  • 1
  • 8
  • 15
  • Thanks, J.Salas, I had a feeling it was something small and silly. I can see from the link to the other StackOverflow post, that double quotes was used for field names like addr1, addr2 etc. However, I did not get any Address data during my test. Something is not right. I'm using the Free Plan from MailChimp. I don't know if this is a limitation where I might to have to upgrade to a new plan to send Address details. I'll contact MailChimp to confirm if this is the case. Thanks for your help! – jova85 Jan 11 '22 at 09:31
  • 1
    A wee follow up. I can confirm this solution works. Some of the address fields were required so when I didn't set them, the Address fields were left blank. As soon as I started setting data for mandatory fields, addr1, city, zip, and country, the address were populated on MailChimp website. All sorted now. Thanks – jova85 Jan 12 '22 at 13:59