This project is read-only.

Custom Fields

Dec 24, 2014 at 3:02 PM
I am trying to create a subscriber with custom fields but getting error with status Unathorize.

Any one know the way to create new custom fields and sending values while creating new subscriber through API then please share the solution.

Virendra
Dec 29, 2014 at 2:50 PM
I find solution.

If you want to send custom fields while creating new subscriber.

foreach (List list in account.lists().entries)
            {
                if (list.id.ToString() == "123456" || list.name == "my list name")//list id i.e. numeric value from list name
                {
                    BaseCollection<Subscriber> target = list.subscribers();
                    SortedList<string, object> parameters = new SortedList<string, object>();
                    parameters.Add("email", "myemail@email.com");
                    parameters.Add("name", "my name");//optional
                    Dictionary<string, object> custom = new Dictionary<string, object>();
                    foreach (KeyValuePair<string, string> k in Data)
                    {
                        custom.Add(k.Key, k.Value);
                    }
                    parameters.Add("custom_fields", new JavaScriptSerializer().Serialize(custom));//this is important
                    Subscriber subscriber = target.create(parameters);
                }
Jan 27, 2016 at 7:53 AM
Very good! also i suggest you to look at my patch to updating an existing subscriber bug, this cant be fixes without re-compiling the library