无效的参考ID:Line.SalesItemLineDetail.ItemRef

时间:2017-05-04 12:09:07

标签: quickbooks quickbooks-online

我尝试使用quickbook api在quickbook中创建销售收据。我的大部分销售收据都是快速成功创建的,没有任何问题。但Quickbook api抛出一个订单的例外。我有以下错误:

{
  "Fault": {
    "Error": [
      {
        "Message": "Invalid Reference Id",
        "Detail": "Invalid Reference Id : Line.SalesItemLineDetail.ItemRef",
        "code": "2500",
        "element": "Line.SalesItemLineDetail.ItemRef"
      }
    ],
    "type": "ValidationFault"
  },
  "time": "2017-05-04T03:32:18.942-07:00"
}

以下是我尝试使用API​​的json:

{  
   "SalesReceiptEx":null,
   "AutoDocNumber":null,
   "CustomerRef":{  
      "name":"Alexander",
      "type":null,
      "value":"325"
   },
   "CustomerMemo":null,
   "BillAddr":{  
      "Id":"1",
      "Line1":"Alexander Kryukov",
      "Line2":"22 Chester Terrace",
      "Line3":"London",
      "Line4":"United Kingdom,GB",
      "Line5":"NW1 4ND",
      "City":null,
      "Country":null,
      "CountryCode":null,
      "CountrySubDivisionCode":null,
      "PostalCode":null,
      "PostalCodeSuffix":null,
      "Lat":null,
      "Long":null,
      "Tag":null,
      "Note":null
   },
   "ShipAddr":{  
      "Id":"2",
      "Line1":"Alexander Kryukov",
      "Line2":"22 Chester Terrace",
      "Line3":null,
      "Line4":null,
      "Line5":null,
      "City":"London",
      "Country":"United Kingdom",
      "CountryCode":null,
      "CountrySubDivisionCode":"GB",
      "PostalCode":"NW1 4ND",
      "PostalCodeSuffix":null,
      "Lat":null,
      "Long":null,
      "Tag":null,
      "Note":null
   },
   "RemitToRef":null,
   "ClassRef":null,
   "SalesTermRef":null,
   "DueDate":null,
   "SalesRepRef":null,
   "PONumber":null,
   "FOB":null,
   "ShipMethodRef":null,
   "ShipDate":null,
   "TrackingNum":null,
   "GlobalTaxCalculation":null,
   "TotalAmt":"136.90000",
   "HomeTotalAmt":null,
   "ApplyTaxAfterDiscount":null,
   "TemplateRef":null,
   "PrintStatus":null,
   "EmailStatus":null,
   "BillEmail":{  
      "Id":null,
      "Address":"sash_300@hotmail.com",
      "Default":null,
      "Tag":null
   },
   "ARAccountRef":null,
   "Balance":null,
   "HomeBalance":null,
   "FinanceCharge":null,
   "PaymentMethodRef":null,
   "PaymentRefNum":null,
   "PaymentType":null,
   "CheckPayment":null,
   "CreditCardPayment":null,
   "DepositToAccountRef":{  
      "name":"Business Bank Account HSBC",
      "type":null,
      "value":58
   },
   "DeliveryInfo":null,
   "DiscountRate":null,
   "DiscountAmt":null,
   "GovtTxnRefIdentifier":null,
   "DocNumber":1163080716,
   "TxnDate":"2017-05-04",
   "DepartmentRef":null,
   "CurrencyRef":null,
   "ExchangeRate":null,
   "PrivateNote":null,
   "TxnStatus":null,
   "LinkedTxn":null,
   "Line":[  
      {  
         "Id":1,
         "LineNum":1,
         "Description":"Flowery Floater Birthday Number",
         "Amount":"43.29167",
         "LinkedTxn":null,
         "DetailType":"SalesItemLineDetail",
         "PaymentLineDetail":null,
         "DiscountLineDetail":null,
         "TaxLineDetail":null,
         "SalesItemLineDetail":{  
            "ServiceDate":null,
            "TaxInclusiveAmt":null,
            "DiscountRate":null,
            "DiscountAmt":null,
            "SalesItemLineDetailEx":null,
            "ItemRef":{  
               "name":"Flowery Floater Birthday Number",
               "type":null,
               "value":"1"
            },
            "ClassRef":null,
            "UnitPrice":"43.29167",
            "RatePercent":null,
            "PriceLevelRef":null,
            "MarkupInfo":null,
            "Qty":"1",
            "UOMRef":null,
            "ItemAccountRef":null,
            "InventorySiteRef":null,
            "TaxCodeRef":{  
               "name":null,
               "type":null,
               "value":2
            }
         },
         "DescriptionLineDetail":null,
         "ItemBasedExpenseLineDetail":null,
         "AccountBasedExpenseLineDetail":null,
         "DepositLineDetail":null,
         "PurchaseOrderItemLineDetail":null,
         "ItemReceiptLineDetail":null,
         "JournalEntryLineDetail":null,
         "GroupLineDetail":null,
         "SubTotalLineDetail":null,
         "TDSLineDetail":null,
         "CustomField":null,
         "LineEx":null
      },
      {  
         "Id":2,
         "LineNum":2,
         "Description":"Custom Product",
         "Amount":"37.50000",
         "LinkedTxn":null,
         "DetailType":"SalesItemLineDetail",
         "PaymentLineDetail":null,
         "DiscountLineDetail":null,
         "TaxLineDetail":null,
         "SalesItemLineDetail":{  
            "ServiceDate":null,
            "TaxInclusiveAmt":null,
            "DiscountRate":null,
            "DiscountAmt":null,
            "SalesItemLineDetailEx":null,
            "ItemRef":{  
               "name":"Custom Product",
               "type":null,
               "value":"10"
            },
            "ClassRef":null,
            "UnitPrice":"3.75000",
            "RatePercent":null,
            "PriceLevelRef":null,
            "MarkupInfo":null,
            "Qty":"10",
            "UOMRef":null,
            "ItemAccountRef":null,
            "InventorySiteRef":null,
            "TaxCodeRef":{  
               "name":null,
               "type":null,
               "value":2
            }
         },
         "DescriptionLineDetail":null,
         "ItemBasedExpenseLineDetail":null,
         "AccountBasedExpenseLineDetail":null,
         "DepositLineDetail":null,
         "PurchaseOrderItemLineDetail":null,
         "ItemReceiptLineDetail":null,
         "JournalEntryLineDetail":null,
         "GroupLineDetail":null,
         "SubTotalLineDetail":null,
         "TDSLineDetail":null,
         "CustomField":null,
         "LineEx":null
      },
      {  
         "Id":3,
         "LineNum":3,
         "Description":"Additional Delivery Charge",
         "Amount":"30.00000",
         "LinkedTxn":null,
         "DetailType":"SalesItemLineDetail",
         "PaymentLineDetail":null,
         "DiscountLineDetail":null,
         "TaxLineDetail":null,
         "SalesItemLineDetail":{  
            "ServiceDate":null,
            "TaxInclusiveAmt":null,
            "DiscountRate":null,
            "DiscountAmt":null,
            "SalesItemLineDetailEx":null,
            "ItemRef":{  
               "name":"Additional Delivery Charge",
               "type":null,
               "value":"1"
            },
            "ClassRef":null,
            "UnitPrice":"30.00000",
            "RatePercent":null,
            "PriceLevelRef":null,
            "MarkupInfo":null,
            "Qty":"1",
            "UOMRef":null,
            "ItemAccountRef":null,
            "InventorySiteRef":null,
            "TaxCodeRef":{  
               "name":null,
               "type":null,
               "value":2
            }
         },
         "DescriptionLineDetail":null,
         "ItemBasedExpenseLineDetail":null,
         "AccountBasedExpenseLineDetail":null,
         "DepositLineDetail":null,
         "PurchaseOrderItemLineDetail":null,
         "ItemReceiptLineDetail":null,
         "JournalEntryLineDetail":null,
         "GroupLineDetail":null,
         "SubTotalLineDetail":null,
         "TDSLineDetail":null,
         "CustomField":null,
         "LineEx":null
      },
      {  
         "Id":4,
         "LineNum":4,
         "Description":"Shipping Cost",
         "Amount":"3.29167",
         "LinkedTxn":null,
         "DetailType":"SalesItemLineDetail",
         "PaymentLineDetail":null,
         "DiscountLineDetail":null,
         "TaxLineDetail":null,
         "SalesItemLineDetail":{  
            "ServiceDate":null,
            "TaxInclusiveAmt":null,
            "DiscountRate":null,
            "DiscountAmt":null,
            "SalesItemLineDetailEx":null,
            "ItemRef":{  
               "name":"Shipping Cost",
               "type":null,
               "value":"1"
            },
            "ClassRef":null,
            "UnitPrice":"3.29167",
            "RatePercent":null,
            "PriceLevelRef":null,
            "MarkupInfo":null,
            "Qty":"1",
            "UOMRef":null,
            "ItemAccountRef":null,
            "InventorySiteRef":null,
            "TaxCodeRef":{  
               "name":null,
               "type":null,
               "value":2
            }
         },
         "DescriptionLineDetail":null,
         "ItemBasedExpenseLineDetail":null,
         "AccountBasedExpenseLineDetail":null,
         "DepositLineDetail":null,
         "PurchaseOrderItemLineDetail":null,
         "ItemReceiptLineDetail":null,
         "JournalEntryLineDetail":null,
         "GroupLineDetail":null,
         "SubTotalLineDetail":null,
         "TDSLineDetail":null,
         "CustomField":null,
         "LineEx":null
      }
   ],
   "TxnTaxDetail":null,
   "TxnSource":null,
   "TaxFormType":null,
   "TaxFormNum":null,
   "TransactionLocationType":null,
   "Id":null,
   "SyncToken":null,
   "MetaData":null,
   "CustomField":null,
   "AttachableRef":null,
   "domain":null,
   "status":null,
   "sparse":null
}

有人可以建议,这个请求的实际问题是什么?

2 个答案:

答案 0 :(得分:1)

错误消息确切表明问题所在:

        "Message": "Invalid Reference Id",
        "Detail": "Invalid Reference Id : Line.SalesItemLineDetail.ItemRef",
        "code": "2500",
        "element": "Line.SalesItemLineDetail.ItemRef"

根据您的请求,您似乎只是在发明这些值,而不是实际从QuickBooks查询这些值。

我假设这是因为在一个地方你的项目被称为一件事,而在另一个地方它被称为完全不同的东西:

"ItemRef":{  
               "name":"Shipping Cost",
               "type":null,
               "value":"1"
            },

即使Id value在两种情况下都相同(1):

"ItemRef":{  
               "name":"Additional Delivery Charge",
               "type":null,
               "value":"1"
            },

你不能只发明这些数字。它们是您必须从Intuit查询的Id值。

通过执行以下方式查询:

SELECT * FROM Item 

答案 1 :(得分:0)

尝试提交ID超出QuickBooks沙盒中可用ID范围的发票行项目时,出现此错误。

例如,我的生产应用程序具有约50个类别,而沙盒仅具有约20个类别,因此尝试在沙盒中使用ID 40会导致此错误。

要解决该问题,我只是减少了ID以便进行测试。