Hi,
I would greatly appreciate your help with some difficulty I’m having automating the creation of invoices in Xero. I successfully set various Invoice properties. However in addition to the Invoice properties, I have to pass through a list of the line items for the invoice.
The challenge I’m having is passing my dynamic LineItems list through to the Xero.Invoices.CreateInvoice function in a valid way.
I have built the list of line items using a string variable called x and lets consider the following example. Consider that x contains the following string data:
[{“Description”:“S BURGER BUNS”, “Quantity”:600.0, “UnitAmount”:2.0, “ItemCode”:“FBOO5”, “Tracking”:[{“Name”:“Stores”,“Option”:“ABC Burgers”}]},{“Description”:“S BURGER BUN 50G”, “Quantity”:30.0, “UnitAmount”:1.2066666667, “ItemCode”:“SBBB”, “Tracking”:[{“Name”:“Stores”,“Option”:“ABC Burgers”}]},{“Description”:“S HERO ROLL”, “Quantity”:6.0, “UnitAmount”:2.1, “ItemCode”:“FB001”, “Tracking”:[{“Name”:“Stores”,“Option”:“ABC Burgers”}]}]
In Xero.Invoices.CreateInvoice, I have set the LineItems property to “=x”, yet when I run my project I get the following error:
Could not cast or convert from System.String to System.Collections.Generic.List`1[Twenty57.Linx.Components.Xero.Entities.Common.Types.Compiled.LineItem]
However, if I literally paste in the above string data into the LineItems property, it works perfectly.
PS: I have also built a LIST variable and tried passing that through to the LineItems property instead of the above string variable x - but get the identical error message.