When making an API call using the .NET library for invoices, the tracking categories on the invoice lines have OptionId as en empty GUID. See below.
I'm setting the UpdatedDateUTC
and it returns one result.
.NET Code
var query = api.Invoices.Page(page);
page++;
if (lastUpdatedTime.HasValue)
{
query = query.ModifiedSince(lastUpdatedTime.Value.AsUtc());
}
invoices = query.OrderBy("UpdatedDateUTC").Find();
Tracking category Object in Visual Studio
{Xero.Api.Core.Model.ItemTrackingCategory}
Errors: null
Id: {11692cb7-597c-4064-a4ac-655c60cedd0f}
Name: "Sales Rep"
Option: "Rob"
OptionId: {00000000-0000-0000-0000-000000000000}
ValidationStatus: Ok
Warnings: null
When I use the API previewer at api.xero.com I get the following JSON which shows the correct ids. Is there an issue with the .NET library? I was version 2.2.1.6 and tried upgrading to the latest nuget package version 2.2.1.12 with the same issue.
This has been working previously but recently stopped working correctly.
Response from Xero API Previewer (api.xero.com)
{
"Id": "773e95c2-cec5-4f02-90c9-8c224b246e4f",
"Status": "OK",
"ProviderName": "Xero API Previewer",
"DateTimeUTC": "\/Date(1521545151271)\/",
"Invoices": [
{
"Type": "ACCREC",
"InvoiceID": "87fc8996-d881-47af-9c26-479705bbfb8a",
"InvoiceNumber": "INV-0088",
"Reference": "",
"Prepayments": [],
"Overpayments": [],
"CISDeduction": 0.00,
"AmountDue": 12000.00,
"AmountPaid": 0.00,
"SentToContact": false,
"CurrencyRate": 1.000000,
"HasErrors": false,
"IsDiscounted": false,
"HasAttachments": false,
"Attachments": [],
"Contact": {
"ContactID": "1bbc04e6-0c4a-4dca-9249-b9369759515b",
"ContactStatus": "ACTIVE",
"Name": "ELP Aviation",
"EmailAddress": "",
"BankAccountDetails": "",
"Addresses": [
{
"AddressType": "STREET",
"City": "",
"Region": "",
"PostalCode": "",
"Country": ""
},
{
"AddressType": "POBOX",
"City": "",
"Region": "",
"PostalCode": "",
"Country": ""
}
],
"Phones": [
{
"PhoneType": "DEFAULT",
"PhoneNumber": "",
"PhoneAreaCode": "",
"PhoneCountryCode": ""
},
{
"PhoneType": "DDI",
"PhoneNumber": "",
"PhoneAreaCode": "",
"PhoneCountryCode": ""
},
{
"PhoneType": "FAX",
"PhoneNumber": "",
"PhoneAreaCode": "",
"PhoneCountryCode": ""
},
{
"PhoneType": "MOBILE",
"PhoneNumber": "",
"PhoneAreaCode": "",
"PhoneCountryCode": ""
}
],
"UpdatedDateUTC": "\/Date(1520356343967+0000)\/",
"ContactGroups": [],
"IsSupplier": false,
"IsCustomer": true,
"DefaultCurrency": "USD",
"SalesTrackingCategories": [],
"PurchasesTrackingCategories": [],
"ContactPersons": [],
"HasValidationErrors": false
},
"DateString": "2018-03-16T00:00:00",
"Date": "\/Date(1521158400000+0000)\/",
"DueDateString": "2018-03-17T00:00:00",
"DueDate": "\/Date(1521244800000+0000)\/",
"Status": "AUTHORISED",
"LineAmountTypes": "Exclusive",
"LineItems": [
{
"ItemCode": "1YR",
"Description": "SaaS 1 Year",
"UnitAmount": 12000.00,
"TaxType": "NONE",
"TaxAmount": 0.00,
"LineAmount": 12000.00,
"AccountCode": "DEFREV",
"Tracking": [
{
"Name": "Revenue",
"Option": "New Business",
"TrackingCategoryID": "b054bce6-95e4-49b3-8d3f-6ed35554189c",
"TrackingOptionID": "509df853-d8d7-4450-b2d8-1d00fe9619a0"
},
{
"Name": "Sales Rep",
"Option": "Rob",
"TrackingCategoryID": "11692cb7-597c-4064-a4ac-655c60cedd0f",
"TrackingOptionID": "7a65b8c4-bba8-457c-9ddf-38d6442b2d49"
}
],
"Quantity": 1.0000,
"LineItemID": "c2b527cb-6677-4853-bb52-7263cba71ef9",
"ValidationErrors": []
}
],
"SubTotal": 12000.00,
"TotalTax": 0.00,
"Total": 12000.00,
"UpdatedDateUTC": "\/Date(1521230140920+0000)\/",
"CurrencyCode": "USD"
}
]
}
Raw response from Fiddler:
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Date: Mon, 19 Mar 2018 00:14:33 GMT
Strict-Transport-Security: max-age=31536000
WWW-Authenticate: OAuth Realm="api.xero.com"
Xero-Cell: egeby
Content-Length: 2187
Connection: keep-alive
{
"Id": "f9e4425a-a6fb-4682-b1b0-5ef1c9245727",
"Status": "OK",
"ProviderName": "AppNamePrivate (Demo)",
"DateTimeUTC": "\/Date(1521418474071)\/",
"Invoices": [
{
"Type": "ACCREC",
"InvoiceID": "87fc8996-d881-47af-9c26-479705bbfb8a",
"InvoiceNumber": "INV-0088",
"Reference": "",
"Payments": [],
"CreditNotes": [],
"Prepayments": [],
"Overpayments": [],
"AmountDue": 12000.00,
"AmountPaid": 0.00,
"AmountCredited": 0.00,
"CurrencyRate": 1.000000,
"HasErrors": false,
"IsDiscounted": false,
"HasAttachments": false,
"Contact": {
"ContactID": "1bbc04e6-0c4a-4dca-9249-b9369759515b",
"Name": "ELP Aviation",
"Addresses": [],
"Phones": [],
"ContactGroups": [],
"ContactPersons": [],
"HasValidationErrors": false
},
"DateString": "2018-03-16T00:00:00",
"Date": "\/Date(1521158400000+0000)\/",
"DueDateString": "2018-03-17T00:00:00",
"DueDate": "\/Date(1521244800000+0000)\/",
"Status": "AUTHORISED",
"LineAmountTypes": "Exclusive",
"LineItems": [
{
"ItemCode": "1YR",
"Description": "SaaS 1 Year",
"UnitAmount": 12000.0000,
"TaxType": "NONE",
"TaxAmount": 0.00,
"LineAmount": 12000.00,
"AccountCode": "DEFREV",
"Tracking": [
{
"Name": "Revenue",
"Option": "New Business",
"TrackingCategoryID": "b054bce6-95e4-49b3-8d3f-6ed35554189c",
"Options": []
},
{
"Name": "Sales Rep",
"Option": "Rob",
"TrackingCategoryID": "11692cb7-597c-4064-a4ac-655c60cedd0f",
"Options": []
}
],
"Quantity": 1.0000,
"LineItemID": "c2b527cb-6677-4853-bb52-7263cba71ef9"
}
],
"SubTotal": 12000.00,
"TotalTax": 0.00,
"Total": 12000.00,
"UpdatedDateUTC": "\/Date(1521230140920+0000)\/",
"CurrencyCode": "USD"
}
]
}
Missing information
As you can see the Fiddler response is missing the TackingOptionId that the API Previewer has. Invoice.LineItems[].Tracking[].TrackingOptionId