.NET wrapper batch import problem

Hello,

I'm using the .NET wrapper to batch-import subscribers, as it says in sample:

BulkImportResults importResults = null;
1    try {
2        importResults = subscriber.Import(addupdate, false);
3    }
4    catch (CreatesendException ex){
5        ErrorResult<BulkImportResults> error = (ErrorResult<BulkImportResults>)ex.Data["ErrorResult"];
6        if (error.ResultData != null) {
7            ....
8        }       
9    }

However, I'm receiving an error on line 5: Unable to cast object of type 'createsend_dotnet.ErrorResult' to type 'createsend_dotnet.ErrorResult`1[createsend_dotnet.BulkImportResults]'.

Anybody has an idea why?

Thanks,

Audrius Stonkus

audrius, 5 years ago

Looks like a bug in .NET wrapper. After downloading the source of the wrapper, I changed this in the file HttpHelper.cs, method ThrowReworkedCustomException:

                try
                {
                    result = JsonConvert.DeserializeObject<ErrorResult>(response);
                }

into:

                try
                {
                    result = JsonConvert.DeserializeObject<EX>(response);
                }

This fixed the problem. I used version 1.1.0-1-gcdc3c11 of the wrapper.

200,000 companies around the world can't be wrong.

From Australia to Zimbabwe, and everywhere in between, companies count on 
Campaign Monitor for email campaigns that drive real business results.

Get started for free
1-888-533-8098