This repository was archived by the owner on Jul 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Example: subscriber modification
Stefano Varesi edited this page Apr 9, 2015
·
2 revisions
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ContactLabAPIClient;
using ContactLabAPIClient.ClabService;
namespace ContactLabApiClientExample
{
public class UpdateExistingSubscriber
{
public static void Main()
{
int SubscriberSourceId = 1;
int SubscriberId = 1;
ClabServiceClient ClabServiceClient = new ClabServiceClient();
Subscriber Subscriber = new Subscriber();
SubscriberAttribute Email = new SubscriberAttribute();
Email.key = "EMAIL";
Email.value = "lamiamail@contactlabo.it";
SubscriberAttribute FirstName = new SubscriberAttribute();
FirstName.key = "FIRSTNAME";
FirstName.value = "mail";
SubscriberAttribute LastName = new SubscriberAttribute();
LastName.key = "LASTNAME";
LastName.value = "lamia";
SubscriberAttribute[] attributesList = { Email, FirstName, LastName };
Subscriber.attributes = attributesList;
Subscriber.identifier = SubscriberId;
// remember to put a true the field ending with "Specified" when needed
Subscriber.identifierSpecified = true;
try
{
AuthToken Token = ClabServiceClient.borrowToken(ContactlabApiClientExamples.Properties.Settings.Default.ApiKey, ContactlabApiClientExamples.Properties.Settings.Default.UserKey);
Subscriber = ClabServiceClient.updateSubscriber(Token, SubscriberSourceId, Subscriber);
ClabServiceClient.invalidateToken(Token);
Console.WriteLine("Updated new subscriber " + Subscriber.attributes[0].key + " with id " + Subscriber.identifier);
}
catch (Exception e)
{
Console.WriteLine("Exception with message " + e.Message);
}
Console.ReadLine();
}
}
}