Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Wrapper libraries >

Value cannot be null. Parameter name: String

Started by Lola Richard -   in Wrapper libraries

Hi

Suddenly the Xero.Api we were using stopped working 2 days ago. I'm able to connect but any calls to the API produce this error. I use XeroAPI.dll wrapper version 1.1.0.33. I'd be grateful for any help. Thank you.
Full stacktrace is:
System.ArgumentNullException
HResult=0x80004003
Message=Value cannot be null.
Parameter name: String
Source=mscorlib
StackTrace:
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at DevDefined.OAuth.Consumer.ConsumerResponse..ctor(HttpWebResponse webResponse, TimeSpan timeTaken)
 

Lola Richard  

Hi Lola,

Could you please confirm for me if the SDK you're using is this one: (https://github.com/XeroAPI/XeroAPI.Net)?

Cheers,

Steven.
 

Steven Brown (Xero Staff)  

Hi, Thanks. Yes it is that one.
 

Lola Richard  

Hi,

We've also been having this issue since a few days ago. We're using XeroAPI.Net 1.1.0.33 from NuGet.

Thanks
 

Accounts 51Degrees  

We are suddenly having the same problem. It's been working fine up until the xero service issues on 11/6 and 11/7. We've been getting "Value cannot be null" ever since.
 

Charles N  

Hi all,

We recently made a config change to support gzip compression for API requests so the logs can be saved in smaller size. This is not a code change only a configuration one.

Whilst this has worked without problems for the vast majority of apps, we have since found that apps using the older (now deprecated) .net wrapper have encountered issues.

Our logs show that the requests themselves was processed successfully but once it reached the SDK, it read the content-length as null.

We have updated the SDK here to fix the issue - https://www.nuget.org/packages/XeroAPI.Net/1.1.0.34

Sorry for the confusion whilst this was investigated.

You may also consider upgrading to the new .NET SDK - https://developer.xero.com/documentation/libraries/using-the-xero-api-with-c
 

Welli Abdullah (Xero Staff)  

Thank you ... will you also push the source that changed for 1.1.0.34 to github so we can pick up the fix? We don't actually use that SDK however some of our patterns were derived from it so being able to see how you fixed it will help us immensely.
 

Charles N  

Hi Charles,

We were in a bit of a rush to get the change into nuget yesterday so we haven't pushed it to github yet. I'll get this done today hopefully, but in the mean time the only change was on line 60 of the ConsumerResponse.cs (https://github.com/XeroAPI/XeroAPI.Net/blob/6791bc4825f043b1f3b6bc2db26e0e32aecf4d80/source/XeroApi/OAuth/Consumer/ConsumerResponse.cs#L60) where we changed it from just checking for an empty string to using !string.IsNullOrEmpty() to test as for some reason it seems like the SDK is nulling out the header...
In the SDK the content length is only used for logging, but if you're wanting to use it for anything else then I suspect you'll need to update the version of dotnet you're running.

Cheers,

Steven.
 

Steven Brown (Xero Staff)  

Steven, thank you for the very quick response & confirmation -- we literally just found & made that same change, and it seems to have fixed the issue. Thank you again.
 

Charles N  

Steven, Welli, thank you both for your quick response!
 

Accounts 51Degrees  

I have an intranet web site that uses the Xero API. I use C# / Razor. In this snippet I'm looking for invoices within the previous month and up until today:
allInvoices = repository.Invoices
.Where(b => b.Date >= firstlast & b.Date < today & b.Type == "ACCPAY")
.ToList();

I am getting the same "Value cannot be null. Parameter name: String" error message but, after narrowing the date range down, only for an invoice or invoices on one particular date. All other dates read the data fine, so I think I have a separate issue with the data. Is there a way to identify which data field is causing the problem? Thanks.
 

Paul Andrews  

Hi Paul,

If you have confirmed that you're not using the old SDK then I would suggest opening a support ticket so we can get more info about calls from you.

If you are using the old SDK then the first step is to update it to the latest version and check if it still has the error.

If you are using the old SDK, have already updated, and are still getting the error, then once again the best thing to do would be to open a support ticket.

Cheers,

Steven.
 

Steven Brown (Xero Staff)