Add subscriber with Multi-Options (select many) custom field via pytho

My list has a custom filed defined like this:

Group (edit)    [Group,fallback=]    Multi-Options (select many)

I'm trying to add subscribers to this list via the python wrapper. I am able to add the subscriber, but the "Group" custom field isn't getting updated (it remains empty). Here's an example of my API call:

custom_fields = [ { "Key" : "Group", "Value" : "TaskPaper||WriteRoom" } ]
subscriber.add("myhiddenlistid", email, name, custom_fields, True)

I think I must be formatting the custom_fields incorrectly, but I'm not sure what I'm doing wrong. In the above example my intention is to subscribe the user and add them to both the "TaskPaper" and "WriteRoom" groups.

Can someone tell me what I'm doing wrong?

Thanks,
Jesse

tobyb tobyb, 5 years ago

Hi Jesse,

To specify multiple options via the api you just send multiple key/value pairs. Try changing your code to:

custom_fields = [ { "Key" : "Group", "Value" : "WriteRoom" }, {"Key": "Group", "Value": "TaskPaper"} ]
subscriber.add("myhiddenlistid", email, name, custom_fields, True)
benmay, 5 years ago

Hello, I'm having the same issue..


PHP:

        $wrap = new CS_REST_Subscribers($list_api_key, $client_api_key, 'http');
       
        $data =    array(
                        'EmailAddress'     =>  $email,
                        'Name'             =>  $name,
                        'CustomFields'     =>  array(
                        array(
                            'Key'     => 'Community',
                            'Value' => 'Brisbane'
                        ),
                        array(
                            'Key'     => 'Community',
                            'Value' => 'Sydney'
                        ),
                        array(
                            'Key'     => 'Interests',
                            'Value' => 'Cats'
                        ),
                        array(
                            'Key'     => 'Interests',
                            'Value' => 'Dogs'
                        ),
                        array(
                            'Key'     => 'Interests',
                            'Value' => 'Cars'
                        )
                ),
                        'Resubscribe'     =>     true
                );
       
        $result = $wrap->add($data);


I am getting the Email / Name saved, but those to custom fields are empty..  they are setup as

    Multi-Options (select many)

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