Subscribe via API and Multi-Options (select many) delimiter?

Hi, I tried adding a subscriber with custom fields, including one that is of type "Multi-Options (select many)". It is easy if it is "(select one)", you can just send that one value. However, I have not been able to find a separator character(s) that will work to add this field from the API.

I have tried pipe, double pipe, and comma to no avail. Any suggestions?

Thanks!

Alex D, 7 years ago

You need to send them as an array..

If you using PHP it is like this.

$result = $cm->subscriberAddWithCustomFields('joe@notarealdomain.com', 'Joe Smith', array('Interests' => array('Xbox', 'Basketball'), 'Dog' => 'Fido'));

I like to define the custom fields first to keep it clean..

$email = "joe@notarealdomain.com";
$name = "Joe Smith";
$custom['interests'][]= "Xbox";
$custom['interests'][]= "Basketball";
$custom['Dog']= "Fido";

$result = $cm->subscriberAddWithCustomFields($email, $name, $custom);


Alex Duffield - Owner
InControl Solutions
http://www.incontrolsolutions.com
jrseney, 7 years ago

Thank you for your repsonse, Alex.

Although that is really only half the answer, it led me to look at the PHP API implementation of AddWithCustomFields. It then became apparent that it was just looping through that array, and added the same field multiple times (with the same name).

Thus its just sending:

<SubscriberCustomField>
          <Key>Multi_Foobar</Key>
          <Value>Option 1</Value>
</SubscriberCustomField>
<SubscriberCustomField>
          <Key>Multi_Foobar</Key>
          <Value>Option 2</Value>
</SubscriberCustomField>

Which conveniently shows up in the "snapshot" as Multi_Foobar = Option 1, Option 2

To implement this in my application (web service for Flash to ASP.NET), I just split the value on a delimiter and added to the field list.

Hope this helps someone, and anyone using the .NET implementation!

jrseney, 7 years ago

One more note- looks like there might be a bug in API?

I can only store a single value in a Multi-Option field if I send the field twice, once with the actual value, and once with an empty/wrong/random value.

Can anyone else verify this or is this only with the .NET API implementation?

Thanks for any feedback!

Ben Ben, 7 years ago
jrseney :

I can only store a single value in a Multi-Option field if I send the field twice, once with the actual value, and once with an empty/wrong/random value.

I just ran a quick test with the .NET Sample and I didn't have that problem, I was just able to pass the field through once and it worked.

jrseney, 7 years ago
Ben :

I just ran a quick test with the .NET Sample and I didn't have that problem, I was just able to pass the field through once and it worked.

Thanks for giving that a try. I'll test it again today, I most likely did something wrong.

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