Importing subscribers: customfields are being ignored

I'm using the most recent API and I'm experiencing troubles when importing subscribers to a newly created list. Adding names and email addresses works but passing the the custom fields doesn't. What am I doing wrong?

This is my code: 
         $cmsubarray = array();
         $subcount = 0;
         foreach($customfields as $customfieldkey => $customfieldvalue){
           $fieldvalue = "".$customfieldkey."";
           $cmsubarray[] = array(
            'Key' => "".$customfieldvalue."",
               'Value' => "sdfs"
         );
         $subcount++;
         }
         
         $cmarray[$count] = array(
               'EmailAddress' => $email,
               'Name' => $name,
               'CustomFields' => $cmsubarray
           );
           $count++;
       }

And this is an example of my array:
Array ( [0] => Array ( [EmailAddress] => tim@eways.nl [Name] => Tim Has [CustomFields] => Array ( [0] => Array ( [Key] => firstname [Value] => Tim ) [1] => Array ( [Key] => url [Value] => http://www.eways.nl ) ) ) )

It is possible to define new custom fields when using this request, isn't it? I get a HTTP/1.1 201 Created but when looking in Campaign Monitor I don't see the custom fields I defined.

Any help would be much appreciated.

Phil Phil, 4 years ago

Hi timinho,

It is possible to define new custom fields when using this request, isn't it?

There's your answer. No it's not. You'll need to first create the custom fields, either thorough the application or via the API.

Join 150,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