2017-05-04 105 views
0

我試圖使用quickbook API在quickbook中創建銷售收據。我的大多數銷售收據已成功創建在快速書沒有任何問題。但quickbook api爲一個訂單拋出異常。我有以下錯誤:無效的參考ID:Line.SalesItemLineDetail.ItemRef

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

下面是JSON了我與API嘗試:

{ 
    "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":"[email protected]", 
     "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 
} 

可能有人建議,有什麼實際的問題,這個要求嗎?

回答

0

的錯誤信息表明到底是什麼問題:

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

即使Idvalue S皆相等(1)在這兩種情況下:

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

你不能只發明這些數字。它們是您必須從Intuit查詢的Id值。

查詢他們這樣做:

SELECT * FROM Item