Error code 400.... Why?

I'm using PHP to subscribe people to a list. I want to set the value of a custom field, too, however, and when I include the "CustomFields" array in the "add" request, it bombs with this error:

Failed to deserialize your request.
Please check the documentation and try again.
Fields in error: subscriber

And here's a dump of the add request:

array(4) {
  ["EmailAddress"]=>
  string(25) "josh@xxxxxxxxxxxxxxxx.com"
  ["Name"]=>
  string(11) "Josh xxxxxxx"
  ["Resubscribe"]=>
  bool(true)
  ["CustomFields"]=>
  array(2) {
    ["Key"]=>
    string(7) "ZipCode"
    ["Value"]=>
    string(5) "12345"
  }
}

When I don't include the CustomFields array, it works fine and people are added to the list.

A couple things: The docs for adding subscribers (http://www.campaignmonitor.com/api/subscribers/#adding_a_subscriber) Doesn't mention this error, nor does it identify the existence of a "subscriber" field, which is what the error is referencing.

Anyone ever encountered this before and/or have any suggestions?

Thanks!

roshodgekiss roshodgekiss, 4 years ago

Hey there joshrenaud, may I recommend that you take a look at our PHP wrapper for the Campaign Monitor API? In particular, the sample we have for adding subscribers. I think you'll find that our API is looking for an array within the CustomFields array.

The 400 error is a generic error response when a subscriber can't be added. If you're successfully adding subscribers when you remove CustomFields, there's very likely something in CustomFields that's baffling our API, so good sleuthing!

Thanks, joshrenaud - let us know how you go :)


Get in touch with us on Twitter: http://twitter.com/campaignmonitor
We're also on Facebook: http://facebook.com/campaignmonitor

200,000 companies around the world can't be wrong.

From Australia to Zimbabwe, and everywhere in between, companies count on 
Campaign Monitor for email campaigns that drive real business results.

Get started for free
1-888-533-8098