【问题标题】:Intuit api estimate update 500 errorIntuit api估计更新500错误
【发布时间】:2013-09-20 12:16:41
【问题描述】:

我正在尝试将我们的应用程序与 intuit/quickbooks 集成,并且到目前为止已经取得了巨大的成功。我正在使用以下库来帮助我进行集成:

http://consolibyte.com/downloads/quickbooks-php-devkit/ (2.0稳定版)

我必须修改代码才能使更新调用正常工作。基本上它传递了未设置的自定义字段,并且通过取消设置 QuickBooks_IPP_Service::_update 中的那些,我能够让客户更新按预期工作。我向这个项目的 github 存储库发出了一个拉取请求,显示了这个修复: github.com/consolibyte/quickbooks-php/pull/6

我的下一个目标是让 Estimates 推送到 Intuit。 EstimateService 对象看起来不完整,所以我添加了更新函数,从 CustomerService 对象中复制了它。他们都依赖父服务对象来实际执行操作,所以我希望它能够正常工作。

好吧,它没有。

有趣的是,我一生都无法弄清楚为什么,如果有人能帮助我,我将永远感激不尽。

当我捕获输出并将其放入“intuit api explorer”时,它就可以工作了!从字面上看,从 intuits 端传递到服务器的相同 xml 会导致 200 成功消息,但从我的角度来看,它会因 500 内部服务器错误而窒息。不是最具描述性的错误消息:)

这是一个示例调用(经过编辑以删除安全信息): 每个 conolibytes 请求的 $Service->lastRequest() 输出:

POST https://qbo.intuit.com/qbo27/resource/customer/v2/**realm**/1 HTTP/1.1
Content-Type: application/xml
Authorization: OAuth realm="", oauth_signature_method="HMAC-SHA1", oauth_signature="****", oauth_nonce="***", oauth_timestamp="1379677509", oauth_token="****", oauth_consumer_key="***", oauth_version="1.0"
Content-Length: 952

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Estimate xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:ns2="http://www.intuit.com/sb/cdm/qbopayroll/v1" xmlns:ns3="http://www.intuit.com/sb/cdm/qbo">
<Id idDomain="QBO">1</Id>
<SyncToken>4</SyncToken>
<Header>
    <DocNumber>1001</DocNumber>
    <TxnDate>2013-09-19-07:00</TxnDate>
    <Status>Pending</Status>
    <CustomerId idDomain="QBO">28</CustomerId>
    <SalesTaxCodeId idDomain="QBO">1</SalesTaxCodeId>
    <SalesTaxCodeName>IS_TAXABLE</SalesTaxCodeName>
    <SubTotalAmt>3.00</SubTotalAmt>
    <TaxAmt>0.21</TaxAmt>
    <TotalAmt>3.00</TotalAmt>
</Header>
<Line>
    <Desc>test 2</Desc>
    <Amount>2.00</Amount>
    <Taxable>true</Taxable>
    <UnitPrice>2.00</UnitPrice>
    <Qty>1</Qty>
</Line>
<Line>
    <Desc>TEst</Desc>
    <Amount>1.00</Amount>
    <Taxable>true</Taxable>
    <UnitPrice>1.00</UnitPrice>
    <Qty>1</Qty>
</Line>
<Synchronized>false</Synchronized>

每个 conolibytes 请求的 $Service->lastResponse() 的输出::

HTTP/1.1 500 Internal Server Error
Date: Fri, 20 Sep 2013 17:04:30 GMT
Server: Apache
Set-Cookie: qboeuid=****; path=/; expires=Sat, 20-Sep-14 17:04:30 GMT; domain=.intuit.com
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 190
Connection: close
Content-Type: application/xml

<!--?xml version="1.0" encoding="UTF-8" standalone="yes"?-->
<faultinfo xmlns="http://www.intuit.com/sb/cdm/baseexceptionmodel/xsd">
    <message>Internal Server Error</message>
    <errorcode>500</errorcode>
    <cause>SERVER</cause>
</faultinfo>

在这里查看其他问题,我没有看到他们的解决方案如何应用: "Internal Server Error" on QBO Api Update call QuickBooks API error when updating

我不知道传入的任何自定义字段,这个估计是通过 api 创建的。

对我来说唯一奇怪的是最后的 Synchromized 标签,但是它可以在 intuit api explorer 中使用。编辑:我从在线 Quickbooks 的设置中删除了这个,我仍然得到相同的结果。

再次,如果我将上面的 xml 放入 intuits api explorer 中,它会完美运行。在我这边,我收到一个 500 错误返回。我已尽力提供尽可能多的信息,如果我遗漏了什么,请告诉我。

任何帮助将不胜感激。提前感谢您的宝贵时间。

编辑 来自 cosolibyte 的每个请求的更多代码:

//login info/OAuth is setup before this and I know it works
//I use it elsewhere to successfully add the estimate in the same class
//also i'm able to add/edit/update customers with the same auth code
$this->EstimateService = new QuickBooks_IPP_Service_Estimate();
$Estimate = $this->EstimateService->findById($this->Context, $this->realm, $quickbooks_id);

$Header = $Estimate->getHeader();
$Header->setTaxAmt(number_format($tax_amount, 2));
$Header->setCustomerId($qb_customer_id);
$Header->setTotalAmt(number_format($total_amount, 2));

//this was added when I was trying to figure out what is going on
//Adding this section did not change the status returned from intuit
$Header->remove('BillAddr');
$Header->remove('ShipAddr');
$Header->remove('ToBePrinted');
$Header->remove('ToBeEmailed');
$Header->remove('DiscountTaxable');

$Estimate->setHeader($Header);
//remove all lines from the current estimate to re-add in updated ones  
$Estimate->remove('Line');
foreach($line_items as $item)
{
    $Line = new QuickBooks_IPP_Object_Line();
$Line->setDesc($item['description']);
    if($item['tax_percentage'])
{
        $Line->setTaxable('true');
    }
    $Line->setUnitPrice($item['price']);
    $Line->setQty($item['quantity']);
    $Line->setAmount(number_format(($item['price'] * $item['quantity']), 2));
    $Estimate->addLine($Line);
 }

 //$this->Context, $this->realm are set up properly and work
 $this->EstimateService->update($this->Context, $this->realm, $Estimate->getId(), $Estimate);

【问题讨论】:

  • 你能发布 print($Service->lastRequest()); 的输出吗?和打印($Service->lastResponse());?这将显示 PHP DevKit 发送到 Intuit 的内容,以及您从 Intuit 返回的内容。使用它我们应该能够定位问题。
  • 非常感谢您抽出宝贵时间!我在 $Service->lastReesponse() 输出中添加了 $Service->lastRequest() 输出已经提供。我有其他调用工作正常,所以我假设 HTTP 标头已设置并正常工作。

标签: php intuit-partner-platform quickbooks-online


【解决方案1】:

根据这部分请求:

POST https://qbo.intuit.com/qbo27/resource/customer/v2/**realm**/1 HTTP/1.1

您似乎正在使用QuickBooks_IPP_Service_Customer 实例来尝试添加估算值。

您确定您使用的是正确的服务类实例吗?

你能偶然发布你的代码的 sn-p 吗?

【讨论】:

  • 啊,我从 ServiceCustomer 类中复制更新函数时,我没有更新 QuickBooks_IPP_IDS::RESOURCE_ESTIMATE,并将其保留为 QuickBooks_IPP_IDS::RESOURCE_CUSTOMER。非常感谢!
  • 哇哦!如果您可以将您所做的任何更改通过电子邮件发送给我,那就太好了,我也可以将这些更改合并到我们的夜间构建中!
【解决方案2】:

应从您的请求中删除同步标记。 QBO 直接将数据同步到云端,所以这是一个错误的字段。它仅用于发出 QBD 请求。 在此处检查请求- https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0400_quickbooks_online/estimate

我同意它可能适用于 API 资源管理器,因为资源管理器必须忽略它并只考虑必填字段。 API 资源管理器不使用 SDK。所以,你没有得到错误。 但是当您使用 SDK 连接时,您传递了错误的请求 xml,因此您会收到错误消息。

【讨论】:

  • 我删除了 Synchronized 标签,它返回相同的错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-18
相关资源
最近更新 更多