QBO API V3 - 更新对象时SyncToken不会增加

时间:2013-12-03 15:24:59

标签: intuit-partner-platform

我正在使用QBO V3 API,并在更新时遇到问题。我可以更新一次实体,它成功地返回具有递增的SyncToken的实体,但之后所有后续的Update调用都返回实体不变且具有相同的SyncToken。对于我尝试的所有实体,帐户,发票等都会发生这种情况。

以下是请求和响应的示例。

1ST UPDATE - SUCCESSFUL(SyncToken递增)

请求

POST https://quickbooks.api.intuit.com/v3/company/1234/customer?requestid=29 HTTP/1.1
Content-Type: application/xml
Authorization: OAuth realm="", oauth_signature_method="HMAC-SHA1", oauth_signature="abc",  oauth_nonce="def", oauth_timestamp="1385928116", oauth_token="xyz", oauth_consumer_key="prs", oauth_version="1.0"
Content-Length: 161

<Customer xmlns="http://schema.intuit.com/finance/v3" sparse="true">
<Id>29</Id>
<SyncToken>0</SyncToken>
<GivenName>Test V3 No. 2</GivenName>
</Customer>

RESPONSE

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2013-12-01T12:01:56.797-08:00">
<Customer domain="QBO" sparse="false">
    <Id>29</Id>
    <SyncToken>1</SyncToken>
<MetaData><CreateTime>2013-12-01T12:01:22-08:00</CreateTime><LastUpdatedTime>2013-12-01T12:01:56-08:00</LastUpdatedTime></MetaData><GivenName>Test V3 No. 2</GivenName><FullyQualifiedName>Test V3 #2</FullyQualifiedName><DisplayName>Test V3 #2</DisplayName><PrintOnCheckName>Test V3 #2</PrintOnCheckName><Active>true</Active><Taxable>false</Taxable><Job>false</Job><BillWithParent>false</BillWithParent><Balance>0</Balance><BalanceWithJobs>0</BalanceWithJobs><PreferredDeliveryMethod>Print</PreferredDeliveryMethod></Customer></IntuitResponse>

2ND UPDATE - FAILS(SyncToken不递增)

请求

POST https://quickbooks.api.intuit.com/v3/company/1234/customer?requestid=29 HTTP/1.1
Content-Type: application/xml
Authorization: OAuth realm="", oauth_signature_method="HMAC-SHA1", oauth_signature="abc",  oauth_nonce="def", oauth_timestamp="1385928116", oauth_token="xyz", oauth_consumer_key="prs", oauth_version="1.0"
Content-Length: 160

<Customer xmlns="http://schema.intuit.com/finance/v3" sparse="true">
<Id>29</Id>
<SyncToken>1</SyncToken>
<GivenName>Test V3 No 2</GivenName>
</Customer>

RESPONSE

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2013-12-01T12:02:13.589-08:00">
<Customer domain="QBO" sparse="false">
    <Id>29</Id>
    <SyncToken>1</SyncToken>
<MetaData><CreateTime>2013-12-01T12:01:22-08:00</CreateTime><LastUpdatedTime>2013-12-01T12:01:56-08:00</LastUpdatedTime></MetaData><GivenName>Test V3 No. 2</GivenName><FullyQualifiedName>Test V3 #2</FullyQualifiedName><DisplayName>Test V3 #2</DisplayName><PrintOnCheckName>Test V3 #2</PrintOnCheckName><Active>true</Active><Taxable>false</Taxable><Job>false</Job><BillWithParent>false</BillWithParent><Balance>0</Balance><BalanceWithJobs>0</BalanceWithJobs><PreferredDeliveryMethod>Print</PreferredDeliveryMethod></Customer></IntuitResponse>

由于响应没有给出错误,并且由于更新第一次工作但不是第二次,因此在QuickBooks端会出现某种错误。有没有人有任何想法会导致这种情况,或者我有什么办法可以防止这种情况发生?

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以使用IPP的PHP SDK尝试此调用。我测试了这些电话。我将共享原始XML请求和响应。

PHP Devkit链接 - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits

我在V3 API Explorer中尝试了以下内容。

链接 - https://developer.intuit.com/apiexplorer?apiname=V3QBO#Customer

客户创建

<Customer xmlns="http://schema.intuit.com/finance/v3" sparse="false">
  <GivenName>TEST</GivenName>
  <FamilyName>TestF</FamilyName>
</Customer>

创建回复

<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2013-12-03T19:37:51.045-08:00">
  <Customer domain="QBO" sparse="false"
    <Id>5</Id>
    <SyncToken>0</SyncToken>
    <MetaData>
      <CreateTime>2013-12-03T19:37:51-08:00</CreateTime>
      <LastUpdatedTime>2013-12-03T19:37:51-08:00</LastUpdatedTime>
    </MetaData>
    <GivenName>TEST</GivenName>
    <FamilyName>TestF</FamilyName>
    <FullyQualifiedName>TEST TestF</FullyQualifiedName>
    <DisplayName>TEST TestF</DisplayName>
    <PrintOnCheckName>TEST TestF</PrintOnCheckName>
    <Active>true</Active>
    <Taxable>false</Taxable>
    <Job>false</Job>
    <BillWithParent>false</BillWithParent>
    <Balance>0</Balance>
    <BalanceWithJobs>0</BalanceWithJobs>
    <PreferredDeliveryMethod>Print</PreferredDeliveryMethod>
  </Customer>
</IntuitResponse>

第一次更新请求

<Customer xmlns="http://schema.intuit.com/finance/v3" sparse="true">
    <Id>5</Id>
    <SyncToken>0</SyncToken>
    <GivenName>TEST1</GivenName>
</Customer> 

第一次更新回复

<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2013-12-03T19:40:50.376-08:00">
  <Customer domain="QBO" sparse="false">
    <Id>5</Id>
    <SyncToken>1</SyncToken>
    <MetaData>
      <CreateTime>2013-12-03T19:37:51-08:00</CreateTime>
      <LastUpdatedTime>2013-12-03T19:40:50-08:00</LastUpdatedTime>
    </MetaData>
    <GivenName>TEST1</GivenName>
    <FamilyName>TestF</FamilyName>
    <FullyQualifiedName>TEST TestF</FullyQualifiedName>
    <DisplayName>TEST TestF</DisplayName>
    <PrintOnCheckName>TEST TestF</PrintOnCheckName>
    <Active>true</Active>
    <Taxable>false</Taxable>
    <Job>false</Job>
    <BillWithParent>false</BillWithParent>
    <Balance>0</Balance>
    <BalanceWithJobs>0</BalanceWithJobs>
    <PreferredDeliveryMethod>Print</PreferredDeliveryMethod>
  </Customer>
</IntuitResponse>

第二次更新请求

<Customer xmlns="http://schema.intuit.com/finance/v3" sparse="true">
    <Id>5</Id>
    <SyncToken>1</SyncToken>
    <GivenName>TEST2</GivenName>
</Customer>

第二次更新回复

<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2013-12-03T19:42:05.712-08:00">
  <Customer domain="QBO" sparse="false">
    <Id>5</Id>
    <SyncToken>2</SyncToken>
    <MetaData>
      <CreateTime>2013-12-03T19:37:51-08:00</CreateTime>
      <LastUpdatedTime>2013-12-03T19:42:05-08:00</LastUpdatedTime>
    </MetaData>
    <GivenName>TEST2</GivenName>
    <FamilyName>TestF</FamilyName>
    <FullyQualifiedName>TEST TestF</FullyQualifiedName>
    <DisplayName>TEST TestF</DisplayName>
    <PrintOnCheckName>TEST TestF</PrintOnCheckName>
    <Active>true</Active>
    <Taxable>false</Taxable>
    <Job>false</Job>
    <BillWithParent>false</BillWithParent>
    <Balance>0</Balance>
    <BalanceWithJobs>0</BalanceWithJobs>
    <PreferredDeliveryMethod>Print</PreferredDeliveryMethod>
  </Customer>
</IntuitResponse>

由于