listMergeVarAdd Output returning Exception

Nov 9, 2010 at 4:45 PM


I'm trying to create several MergeVar Fields in a MC List.

This is my code (the ListID is correct because I use it in other places):

Dim VarPOINTS As listMergeVarAddInput = New listMergeVarAddInput(ListID, "POINTS", "POINTS - Description")
Dim AddVars As listMergeVarAdd = New listMergeVarAdd(VarPOINTS)
Dim OutVar As listMergeVarAddOutput = AddVars.Execute()
Return OutVar.result
OutVar gives me the following exception:
"Object reference not set to an instance of an object.     at CookComputing.XmlRpc.XmlRpcStruct.Add(Object key, Object value)    
at PerceptiveMCAPI.Methods.listMergeVarAdd.FormatInput()    at PerceptiveMCAPI.Methods.listMergeVarAdd.ExecuteXmlRpc()"
I interact with other PerceptiveMCAPI methods (MC configuration in web.config) and everything works fine ecxept this.
Thanks for any help!


Nov 9, 2010 at 5:15 PM

This is what I have in Web.config:


Nov 9, 2010 at 5:42 PM

I've run your code against my account and it works fine... hmmm

The point it's failing at is where it creates & formats the XmlRpcStruct object to send to MailChimp -- which is pretty straight forward.

Hard to see how it could fail there, and yet it seems to, eh?

What version of the wrapper are you using? 


Nov 9, 2010 at 5:50 PM
Edited Nov 9, 2010 at 9:11 PM
I'm not at my computer right now but I downloaded the last one not in beta... I will confirm the exact version later today.

Enviado pelo telemóvel.
-- (Later) Hi, I'm using version v1.2.4.
Nov 9, 2010 at 9:41 PM
Edited Nov 9, 2010 at 9:42 PM


I tried again in C# using the latest beta - I also tried against several lists... allways same result.


listMergeVarAddInput VarPOINTS = new listMergeVarAddInput("XXXXXXXXXXXXXXXXXXXXXXXXXX-us1",ListID, "POINTS", "POINTS Description");
listMergeVarAdd AddVars = new listMergeVarAdd(VarPOINTS);
listMergeVarAddOutput OutVar = AddVars.Execute();

Exception (in the same place):

Object reference not set to an instance of an object. at CookComputing.XmlRpc.XmlRpcStruct.Add(Object key, Object value) at
PerceptiveMCAPI.Methods.listMergeVarAdd.FormatInput() in
C:\myProjects\Visual Studio 2008\PerceptiveMCAPI_CodePlex\PerceptiveMCAPI\trunk\List\listMergeVarAdd\listMergeVarAdd.cs:line 75 at
PerceptiveMCAPI.Methods.listMergeVarAdd.ExecuteXmlRpc() in
C:\myProjects\Visual Studio 2008\PerceptiveMCAPI_CodePlex\PerceptiveMCAPI\trunk\List\listMergeVarAdd\listMergeVarAdd.cs:line 57

Any help... greatly appreciated! :)


Nov 9, 2010 at 10:02 PM


I think I found out the problem (downloaded the source code):

Function FormatInput in listMergeVarAdd.cs expects that Input.parms.options.default_value is not null but as these parameters are optional in MC, I wasn't populating them.

Corrected it and the MergeVar fields are now correctly created in any list.



Nov 9, 2010 at 10:52 PM

Muy interesante.

The .dll has a version number -- there were 4 versions of 1.2.4, please check the properties of the dll to see which it is; e.q.

regardless of that, I ran successfully on & v1.2.5.1 -- so something else is going on. 

I need to have you (using the beta please ) run the program in debug, step through to the listMergeVarAdd.FormatInput() function and find which


statement it's puking out on.

Line 75 is the create of the XmlRpcStruct in the beta, but it appears to be getting an exception on trying  to add one of the options -- so I'm thinking that the stack trace above was from the 1.2.4.x version.

... and just for the hell of it, if you want to get passed this on a temp. basis, try running this command as serial/json instead of xml-rpc



Nov 9, 2010 at 11:05 PM

heh.  Got held up on a phone call and when I finally pressed enter (an hour later) you already gave the answer I was suspecting...

You SHOULD NOT have to initialized those parameters, and the input class provides default values (from the MCAPISettings) for the other values in the constructor of the options class, but apparently I expected the default_value property to default to an empty string, which it does for me, but apparently not in your case -- strange.

The default_value was the only property not explicitly initialized in the constructor so it pretty much had to be the culprit -- and I'll change that, but still it's bothers me that it didn't work in your case.



Nov 9, 2010 at 11:27 PM
No prob David,

I just have to thank you for your work. :)


Nov 12, 2010 at 10:02 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.