Minor bug in List API for Create Custom Field

If you try to create a text option custom field and pass an empty string as the options value you get a 400 error code and a rather confusing unable to deserialize error message.

According to the docs either null or an empty field should be fine and an unexpected value in the options should return a 256 error code. (see http://www.campaignmonitor.com/api/lists/#creating_a_custom_field)

So a posted array like this won't work:
array (
  'credentials' => '%%%%%%%%%%%%%%%%',
  'userAgent' => 'CS_REST_Wrapper v1.0.13 PHPv5.2.6-3ubuntu4.6 over cURL with native',
  'contentType' => 'application/json; charset=utf-8',
  'deserialise' => true,
  'host' => 'api.createsend.com',
  'protocol' => 'https',
  'route' => 'https://api.createsend.com/api/v3/lists/%%%%%%%%%%%%%%%%/customfields.json',
  'method' => 'POST',
  'data' => '{"FieldName":"Buddy Status","DataType":"Text","Options":""',

As you can see this is using the create send php wrapper from GitHub

benz, 5 years ago

Oh and even if you delete a list you can still add custom fields to it through the API if you know the List Key - this might be a transient issue if you have a clean up script that runs regularly.

I would have expected a 404 error though so I detect that the operation failed.


shenny, 5 years ago

Hi benz,

Yes you're right, you do get a 400 error when you pass an empty string to the option parameter - this is because it's expecting a variable of type array. You will get the 256 error if you pass an empty array, or if you pass null the operation will actually work. I'll raise a ticket to have our docs reflect this behaviour.

With regards to your second point, when you delete a List using the system (either via the API or app), it  actually just sets the status of the List to "deleted" as opposed to physically deleting the any rows from our database. I'll also raise a ticket on this to determine how we want to handle this moving forward.

Thanks for bringing these issues to our attention!


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