.NET C#跟踪发票行上的类别问题(OptionId为空)

时间:2018-03-18 20:38:27

标签: c# .net xero-api

使用.NET库为发票进行API调用时,发票行上的跟踪类别将OptionId作为空GUID。见下文。

我正在设置UpdatedDateUTC并返回一个结果。

.NET代码

var query = api.Invoices.Page(page);

page++;

if (lastUpdatedTime.HasValue)
{
    query = query.ModifiedSince(lastUpdatedTime.Value.AsUtc());
}

invoices = query.OrderBy("UpdatedDateUTC").Find();

在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

当我在api.xero.com上使用API​​预览器时,我得到以下显示正确ID的JSON。 .NET库有问题吗?我是版本2.2.1.6并尝试升级到最新的nuget包版本2.2.1.12,但问题相同。

此前一直有效,但最近停止了正常工作。

来自Xero API预览程序(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"
    }
  ]
}

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"
    }
  ]
}

缺少信息

正如您所看到的,Fiddler响应缺少API预览器所具有的TackingOptionId。 Invoice.LineItems[].Tracking[].TrackingOptionId

0 个答案:

没有答案