I am successfully retrieving Subscriber records from the database. The Subscriber.Attributes property contains a list of all the Subscriber Attributes we created in the ExactTarget UI, plus the value for the Attribute given by the Subscriber. For each Attribute I have a Name and a Value, but that's about it.
I am also successfully retrieving ListAttribute records. Some of these records match the Subscriber.Attributes, but there is much more detail, such as DefaultValue and Ordinal and IsHidden, that I need for my application.
I am joining my Subscriber.Attributes to my ListAttributes based on the common field of "Name". This isn't ideal. Name isn't unique in the ListAttributes, so the join is returning multiple copies. It seems to me that there should be a way for me to request Subscribers in such a way that Subscriber.Attributes returns an ObjectID in addition to the Name and Value. Then I could join the two lists on ObjectID instead of Name and most of my issues would disappear. Here is the code I'm using to get Subscribers:
private List<Subscriber> RetrieveSubscribers()
{
var Subscribers = new List<Subscriber>();
try
{
SoapClient client = new SoapClient();
client.ClientCredentials.UserName.UserName = _username;
client.ClientCredentials.UserName.Password = _password;
RetrieveRequest request = new RetrieveRequest();
request.ObjectType = "Subscriber";
request.Properties = new String[] { "ID", "SubscriberKey", "EmailTypePreference", "Status" };//, "PartnerProperties"
SimpleFilterPart filterPart = new SimpleFilterPart { SimpleOperator = SimpleOperators.equals };
String[] filterValues = { _email };
filterPart.Property = "EmailAddress";
filterPart.Value = filterValues;
request.Filter = filterPart;
APIObject[] results = null;
String requestId = null;
var status = client.Retrieve(request, out requestId, out results);
if (status.Equals("OK"))
{
foreach (Subscriber s in results)
{
Subscribers.Add(s);
}
}
else
{
ErrorMessage.Text += "Error Retrieving Subscriber: " + status;
ErrorMessage.Text += "<br />";
}
}
catch (Exception exception)
{
if (exception.InnerException != null && !string.IsNullOrWhiteSpace(exception.InnerException.Message))
{
ErrorMessage.Text += exception.InnerException.Message;
}
else
{
ErrorMessage.Text += exception.Message;
}
ErrorMessage.Text += "<br />";
}
return Subscribers;
}