rjbathgate
rjbathgate

Reputation: 319

Xero API > Invoices > PUT > Tracking Categories

Following:

https://developer.xero.com/documentation/api/invoices#post

It suggests you can add a Tracking Category when creating an invoice in the XML format:

<Tracking>
  <TrackingCategoryID>ABC</TrackingCategoryID>
  <Name>Name</TrackingCategoryID>
  <Option>Option</Option>
</Tracking>

Within the

<LineItem>

node

Which is within the

<LineItems>

node

However, when doing this, the API returns:

Object reference not set to an instance of an object.

Which I understand to mean it doesn't recognise an element / node within the XML.

Without the node, everythings works fine, so it's the node and nodes within which cause the problem. Individually testing each sub node within results in the same problem.

I'm pretty sure I'm following the structure as per docs at https://developer.xero.com/documentation/api/invoices#post so if anyone can shed some light as to the correct structure to add Tracking Codes to an invoice line item...!

Most appreciated,

Thanks Rob

Upvotes: 0

Views: 876

Answers (1)

Praemon
Praemon

Reputation: 851

I ran into the same issue. When posting XML for Tracking Options in Xero, the tracking data should be inside a TrackingCategory XML element, such as below:

<Tracking>
    <TrackingCategory>
        <TrackingCategoryID>ABC</TrackingCategoryID>
        <Name>Name</Name>
        <Option>Option</Option>
    </TrackingCategory>
</Tracking>

TrackingCategoryID is optional, and you can have a maximum of 2 TrackingCategory elements.

Upvotes: 1

Related Questions