Reputation: 243
I'm using MailChimp's API v3.0 and having problems when trying to update the subscriber's postal address.
The data I'm sending is:
[method] => patch
[path] => lists/123456789/members/membershash
[url] => https://us13.api.mailchimp.com/3.0/lists/123456789/members/membershash
[body] => {"merge_fields":{"FNAME":"firstname","LNAME":"lastname","TITLE":"Mr","BDAY":"10\/11","TSTATUS":"approved","ADDRESS":{"addr1":"10811 International Drive","city":"Rancho Cordova","state":"CA","zipcode":"95670"}}}
[timeout] => 10
[headers] => PATCH /3.0/lists/123456789/members/membershash HTTP/1.0
The error I'm getting is:
400: Your merge fields were invalid. Please enter a complete address.
I've tried sending it as a string (fields separated by double spaces as described in the import file schema), i.e.
10811 International Drive Rancho Cordova CA 95670
but I got the same error. What am I doing wrong?
Upvotes: 2
Views: 3746
Reputation: 11
What if you have a foreign address? The country would be filled in, but many of them do not have values for the state and zip/postal code.
Upvotes: 0
Reputation: 3893
The "enter a complete address" error will happen if you do not send a value for country
.
Both addr2
and country
are optional, but MailChimp secretly requires you to send an empty string for country
whereas you can leave out addr2
entirely.
MailChimp support told me this:
You are right that the only required parameters of the Address object is addr1, city, state, and zip. That being said, for parity with performance of the application, the "country" parameter would need to be present and be given an empty string value. The empty string will resolve to the default_country. Which if not changed is the US.
I understand that this is not completely consistent with the documentation. I will pass along this feedback to our team that oversees our schema as this can create confusion.
Upvotes: 1
Reputation: 57
Just in case you're still looking... I'm using the Drewm wrapper and updating mailing address by using the following:
$subscriber_hash = $MailChimp->subscriberHash($email);
$result = $MailChimp->patch("lists/$list_id/members/$subscriber_hash", [
'merge_fields' => [
'FNAME' => $firstname,
'LNAME' => $lastname,
'ADDRESS' => array
(
'addr1' => $addline1,
'addr2' => $addline2,
'city' => $city,
'state' => $state,
'zip' => $zip,
'country' => $country
)
],
'interests' => [$interest_id => true],
]);
print_r($result);
Upvotes: 3