0

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

Rob
  • 5,578
  • 3
  • 23
  • 28
  • What should the value be (rather than an empty guid)? – mjwills Mar 18 '18 at 20:41
  • Please show the relevant code (client side or server side - impossible to tell what you are asking). – NightOwl888 Mar 18 '18 at 20:47
  • Can you use something like fiddler to capture the raw response content so we can see if it's being returned by the API at all? – MJMortimer Mar 18 '18 at 20:49
  • Added fiddler response and additional information. Seems the fiddler response is missing the TrackingOptionId. @MJMortimer – Rob Mar 20 '18 at 11:34
  • I'm not sure the API has ever returned the TracjingOptionID when the tracking is embedded in an invoice line item. It's not in our public documentation either. Are you sure you're not getting mixed up with using tracking via the tracking endpoints? – MJMortimer Mar 20 '18 at 18:22
  • Our code in our application has not changed and has worked before using that field. Is "Option" unique in that we could use that to match instead of OptionId? – Rob Mar 20 '18 at 18:53
  • @MJMortimer Just need to know if "Option" (Name) is unique? It's not specified in the API docs but the Xero UI seems to only allow unique names. – Rob Mar 23 '18 at 14:23

0 Answers0