You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xero API问题:报价行项目无法添加Tracking Option

问题:Xero报价行项目无法成功添加Tracking Option

问题概述

创建或更新报价时,尝试为行项目配置Tracking Option,请求Payload格式看似合规,但返回的报价中行项目的Tracking字段始终为空,Xero UI中也显示该字段未设置。已尝试仅传递TrackingOptionID等多种配置组合,均未解决问题。

代码示例

Quote xeroQuote = new()
{
    QuoteID = quote.XeroId ?? null,
    Contact = new()
    {
        ContactID = customer.XeroId
    },
    Reference = quote.Reference,
    CurrencyCode = "GBP",
    Date = DateTime.Now,
    ExpiryDate = quote.ExpiryDate,
    LineItems = quote.Items.Select(x => new LineItem()
    {
        LineItemID = x.XeroLineItemId ?? null,
        ItemCode = x.ItemCode,
        Description = $"Some Description",
        UnitAmount = x.UnitAmount,
        Quantity = x.Quantity,
        LineAmount = x.LineAmount,
        Tracking = new()
        {
            new()
            {
                TrackingCategoryID = x.TrackingGroupOptionParentId,
                Name = x.TrackingGroupName,
                TrackingOptionID = x.TrackingGroupOptionId,
                Option = x.TrackingGroupOptionName
            }
        }
    }).ToList(),
    LineAmountTypes = QuoteLineAmountTypes.EXCLUSIVE
};

请求Payload

{
  "Quotes": [
    {
      "CurrencyCode": "GBP",
      "LineAmountTypes": "EXCLUSIVE",
      "QuoteID": "Guid?",
      "Contact": {
        "ContactID": "Guid?"
      },
      "LineItems": [
        {
          "Description": "Some Description",
          "Quantity": 1,
          "UnitAmount": 15,
          "ItemCode": "GB3-White",
          "LineAmount": 15,
          "Tracking": [
            {
              "TrackingCategoryID": "Guid?",
              "TrackingOptionID": "Guid?",
              "Name": "Category Name",
              "Option": "Option Name"
            }
          ]
        }
      ],
      "Date": "2024-04-05T10:25:07.4838546Z"
    }
  ]
}

注:敏感数据已替换为占位符

复现步骤

  • 使用AccountingApi.UpdateOrCreateQuotesAsync方法创建/更新报价
  • 确认请求Payload格式符合要求
  • 查看返回结果及Xero UI,验证行项目的Tracking字段为空

预期行为

报价行项目中应显示已配置的Tracking Option

排查与解决方案建议

  1. 验证ID有效性:确认TrackingCategoryID和TrackingOptionID对应当前Xero组织中存在且未被删除的追踪类别与选项,避免使用无效ID。
  2. 简化Tracking字段:根据Xero API规范,仅传递TrackingOptionID即可完成配置,无需额外传递Name和Option字段,尝试简化为:
    "Tracking": [
      {
        "TrackingOptionID": "你的有效OptionID"
      }
    ]
    
  3. 检查API权限:确认当前Xero应用拥有accounting.transactions的读写权限,权限不足会导致字段无法被正确写入。
  4. 核对字段大小写:Xero API对JSON字段大小写敏感,确保Tracking、TrackingOptionID等字段的大小写与官方文档完全一致(首字母需大写)。
  5. 测试创建新报价:若为更新现有报价失败,尝试创建全新报价并配置Tracking Option,排除原有行项目的关联问题。

内容的提问来源于stack exchange,提问作者Liam Kenny

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 12:53:19