0

I am getting the error "Value cannot be null. Parameter name: key" at the line xapi.Items.Create(item1) , while creating an inventory item using Github Xero c# lib. What could be wrong?

Here is the c# code:

string xeroAPIUrl = "https://api.xero.com";
PrivateAuthenticator pAuth = new PrivateAuthenticator(@"..\publickey.cer");
Consumer consumer = new Consumer("............", ".................");
XeroCoreApi xapi = new XeroCoreApi(xeroAPIUrl, pAuth, consumer, null, new DefaultMapper(), new DefaultMapper());
Item item1 = new Item();
item1.Id = Guid.NewGuid();
item1.Code = "BTC";
item1.Name = "BITCOIN";
item1.Description = "Bitcoin Entry";
item1.PurchaseDescription = "Bitcoin Purchase";
item1.PurchaseDetails = new PurchaseDetails() { UnitPrice = 100.00m, 
AccountCode = "200" };
item1.SalesDetails = new SalesDetails() { UnitPrice = 110.00m, AccountCode = "300" };
item1 = xapi.Items.Create(item1);

Regards,

Murali

Murali
  • 1
  • 2
    Can you please provide a stack trace so I can see where the error is actually originating from. On first glance I think it's because your supplying the public key .cer file rather than your private key .pfx file to the private authenticator – MJMortimer Jan 25 '18 at 05:17
  • Thanks for pointing out to use privatekey, that fixed the issue. Thank you so much. – Murali Jan 25 '18 at 09:06

0 Answers0