drewm / mailchimp-api

Super-simple, minimum abstraction MailChimp API v3 wrapper, in PHP
MIT License
1.99k stars 506 forks source link

Cannot POST physical address merge fields #262

Open ARH-Digital opened 5 years ago

ARH-Digital commented 5 years ago

When adding a new user, I can use the post method to add a user without issue, however, if I post a new user and include the ADDRESS merge_fields, there are always errors.

Using the same data to PUT or PATCH an existing user works, I just seem to be unable to send a physical address when creating a user.

I am not entirely convinced that this is an issue with your package and may be an issue with MailChimp, but thought I would check here first.

New user request - fails

    'body' => '{"status":"subscribed","email_address":"devonte.koelpin@smitham.net","merge_fields":{"FNAME":"Fredy","LNAME":"Reichert","PHONE":"987654321007","ADDRESS":{"addr1":"925 Isobel Reach","city":"South Lorenberg","state":"QLD","zip":4000,"country":"AU"}}}'

The error given from Mailchimp isn't very helpful,

    detail":"The resource submitted could not be validated. For field-specific details, see the \'errors\' array.","instance":"bd02cc41-1146-41a7-ad80-7aae2189f702","errors":[{"field":"merge_fields.ADDRESS","message":"Data did not match any of the schemas described in anyOf."

Yet the exact data made in 2 requests instead of one appears to work. New User request - Works

    'body' => '{"status":"subscribed","email_address":"devonte.koelpin@smitham.net","merge_fields":{"FNAME":"Fredy","LNAME":"Reichert","PHONE":"987654321007"}}'

Update User request with address - works

    'body' => '{"status":"subscribed","email_address":"devonte.koelpin@smitham.net","merge_fields":{"FNAME":"Fredy","LNAME":"Reichert","PHONE":"987654321007","ADDRESS":{"addr1":"925 Isobel Reach","city":"South Lorenberg","state":"QLD","zip":4000,"country":"AU"}}}'
drewm commented 5 years ago

Did you get anywhere towards solving this?

ARH-Digital commented 5 years ago

No. I ended up not putting a physical address in MailChimp. It might just be a limitation of Mailchimp that it could not all be done at once. Storing the physical address was a nice to have, not a requirement so I was able to leave out that functionality.