2015-12-02 46 views
0

我正在使用QuickBooks Online Plus,这意味着我可以编辑该物品。我想用这个API来改变一个项目的#号。我通过QuickBooks Online Plus创建了一个项目“test1”。当我从API读取项目时,我在附加的json文件中获得了以下内容。事情看起来很大如下:如何使用QuickBooks Online Plus更新手头物品数量

{ 
    "QueryResponse": { 
    "Item": [ 
     { 
     "Name": "test1", 
     "Active": true, 
     "FullyQualifiedName": "test1", 
     "Taxable": false, 
     "UnitPrice": 3, 
     "Type": "Inventory", 
     "IncomeAccountRef": { 
      "value": "60", 
      "name": "Sales of Product Income" 
     }, 
     "PurchaseCost": 1, 
     "ExpenseAccountRef": { 
      "value": "61", 
      "name": "Cost of Goods Sold" 
     }, 
     "AssetAccountRef": { 
      "value": "62", 
      "name": "Inventory Asset" 
     }, 
     "TrackQtyOnHand": true, 
     "QtyOnHand": 6, 
     "InvStartDate": "2015-12-02", 
     "domain": "QBO", 
     "sparse": false, 
     "Id": "19", 
     "SyncToken": "1", 
     "MetaData": { 
      "CreateTime": "2015-12-01T14:38:23-08:00", 
      "LastUpdatedTime": "2015-12-01T14:38:42-08:00" 
     } 
     } 
    ], 
    "startPosition": 1, 
    "maxResults": 1 
    }, 
    "time": "2015-12-02T09:59:29.936-08:00" 
} 

但是,当我尝试使用下面的JSON对象,以更新项目:

{ 
     "Name": "test1", 
     "Active": true, 
     "Taxable": false, 
     "UnitPrice": 3, 
     "Type": "Inventory", 
     "IncomeAccountRef": { 
      "value": "60", 
      "name": "Sales of Product Income" 
     }, 
     "PurchaseCost": 1, 
     "ExpenseAccountRef": { 
      "value": "61", 
      "name": "Cost of Goods Sold" 
     }, 
     "AssetAccountRef": { 
      "value": "62", 
      "name": "Inventory Asset" 
     }, 
     "TrackQtyOnHand": true, 
     "QtyOnHand": 16, 
     "InvStartDate": "2015-12-02", 
     "domain": "QBO", 
     "sparse": false, 
     "Id": "19", 
     "SyncToken": "2" 
} 

,我得到了这样的错误:

{"Fault":{"Error":[{"Message":"Stale Object Error","Detail":"Stale Object Error : You and [email protected] were working on this at the same time. [email protected] finished before you did, so your work was not saved.","code":"5010","element":""}],"type":"ValidationFault"},"time":"2015-12-02T10:42:52.466-08:00"} 

我想更新现有数量。有谁知道什么是错的,以及如何去做?谢谢。

回答

0

问题在于“SyncToken”。我相信,当您尝试更新新项目时,您不应增加“SyncToken”,您应该保持不变。 QBO会为您更新“SyncToken”。

相关问题