1

I just cannot add an Address with the API. I managed to update every other coloumn type, but not the address one.

I tried two ways:

$array['ADDRESS']['addr1'] = 'Amara Locks 12588'
...

didn't work. I got the error message:

400: The resource submitted could not be validated. For field-specific details, see the 'errors' array.

Because of this post I thought I needed to convert it to JSON. It worked for not getting any errors, but the field address stays empty in MailChimp.

Just for an example how the array looks like:

["ADDRESS"]=>
string(124) "{"country":"DE","addr1":"Amara Locks 12588","addr2":"Second Floor","state":"North Dakota","city":"East Kadin","zip":"33183"}"
Philipp Mochine
  • 4,351
  • 10
  • 36
  • 68
  • _For field-specific details, see the 'errors' array._ - and what is in the `errors` array? – Sean Bright Jul 10 '18 at 15:33
  • @SeanBright yeah that is my problem, I don't know how to get the error since I'm working with a wrapper (spatie/laravel-newsletter/ and drewm/mailchimp-api). The only why to see it is with $this->mailChimp->getLastError(); but it gives me the error that I wrote.... – Philipp Mochine Jul 10 '18 at 15:38

2 Answers2

1

So for future readers. Yes the first way was the correct one. But my problem was that some of the values were null, so you need to remove them, e.g.

 $array['ADDRESS']['addr1'] = $address ?? '';
Philipp Mochine
  • 4,351
  • 10
  • 36
  • 68
0
@Philipp Mochine answer is correct.This answer is for all those PHP developer who are 
looking for complete array structure.
array:2 [
"email_address" => "ggdd@gmail.com"
"merge_fields" => array:4 [
"FNAME" => "Hassan"
"LNAME" => "Tahir"
"PHONE" => ""
"ADDRESS" => array:6 [
  "addr1" => "81 street"
  "addr2" => "house no 2"
  "city" => "Lahore"
  "state" => "Punjab"
  "zip" => "54000"
  "country" => "Pakistan"
]]
]
Hassan Tahir
  • 134
  • 9
  • This structure is working for everything else. But for some reason `PHONE` is not working and simply keeping the phone number column empty on their list. Is there any change happen since this is a old answer? – Foysal Remon Apr 25 '22 at 10:50