Feb 24, 2011 at 9:52 AM

I am new at using the API and trying to get the members info including merge tags from MC using the following:

  listMemberInfoInput lmi = new listMemberInfoInput(MCAPISettings.default_apikey, "list_id", "you@cannot.see");
                listMemberInfo lm = new listMemberInfo(lmi);
                listMemberInfoOutput lmo = lm.Execute();

It returns the following:

id: 0123456, email: you@cannot.see, status: subscribed, timestamp: 2/23/2011 1:24:28 PM

How do I get the merge tags?

Any help would be appreciated!

Feb 28, 2011 at 3:25 AM
Edited Feb 28, 2011 at 3:27 AM

looks like what you did was do a...  lmo.result.ToString() -- ToString() in ANY method only give a small fraction of the info available -- actually not terribly helpful in complex output classes like listMemberInfo()

For result sets that are not simple types, the 'result' property is a class instance that you get its sub-properties from - for lack of a better way to describe it - and merge vars are pretty much the nastiest out there. to get you started, since the 'merges' property is defined as a Dictionary<string, object> you need to do something like...

Dictionary<string, object> merge_vars = lmo.result.merges;
foreach (entry in merge_vars)
   // your code here

Now, if all you merge_vars are simple types like string or int, you can just to an entry.Value.ToString(); - but most of us aren't that lucky, so then you have to type check the Value object and handle accordingly.