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, 4 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.

Thanks!

shenny, 4 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!

Cheers,
Shenny.

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098