Quickbooks Php SDK - CheckNullResponseAndThrowException - 响应空或空

时间:2015-04-17 04:22:54

标签: php sdk quickbooks

请帮我解决以下错误: 2015-04-16 10:45:10 - D:\ projects \ QuickBooksv3-php-sdk-2.0.5 \ DataService \ DataService.php - 340 - CheckNullResponseAndThrowException - 响应空或空

3天前,我已成功测试了quickbooks php sdk。 但是今天当我要与系统集成时,它会遇到错误。 代码与3天前相同。

这是我的代码:

//Create new invoice
$invoiceObj2 = new IPPInvoice();
$invoiceObj2->DocNumber="1025";

//Add customer
$customerRef2= new IPPReferenceType();
$customerRef2->value= "1";
$invoiceObj2->CustomerRef= $customerRef2;

//Create Line
$line2 = new IPPLine();
$line2->Amount= 1*90.84;

$linetype2= new IPPLineDetailTypeEnum();
$linetype2->value="SalesItemLineDetail";

$lineDetail2 = new IPPSalesItemLineDetail();
$lineDetail2->ItemRef = "4";
$lineDetail2->UnitPrice = 90.84;
$lineDetail2->Qty= 1;

$line2->DetailType=$linetype2;
$line2->SalesItemLineDetail=$lineDetail2;

$invoiceObj2->Line=$line2;

$resultingInvoiceObj2 = $dataService->Add($invoiceObj2);

echo "Created Invoice Id={$resultingInvoiceObj2->Id}. Reconstructed response body:<br/><br/>";
$xmlBody = XmlObjectSerializer::getPostXmlFromArbitraryEntity($resultingInvoiceObj2, $urlResource);
echo "<pre>";
echo $xmlBody . "<br/>";
echo "</pre>";

请帮助指出我的错误。感谢

2 个答案:

答案 0 :(得分:0)

请更改使用沙箱QBO帐户的基本网址,或使用生产代币连接到现有的QBO帐户。 您的问题可能与此更改有关 - https://developer.intuit.com/v2/blog/2014/10/24/intuit-developer-now-offers-quickbooks-sandboxes

您也可以尝试更改值,然后尝试集成到QB

答案 1 :(得分:0)

我已经解决了同样的问题检查所需的参数。请检查必填字段。

必填字段至少为:

DocNumber
TxnDate
CustomerRef

至少一行记录

Line.DetailType
Line.Amount
Line.Description

至少一个Line.SalesItemLineDetail

Line.SalesItemLineDetail.ItemRef
Line.SalesItemLineDetail.Quantity
Line.SalesItemLineDetail.UnitPrice

我修改了你的代码并运行了。它的工作

最终修改后的代码:

//Create new invoice
$invoiceObj2 = new IPPInvoice();
$invoiceObj2->DocNumber="1025";
$invoiceObj2->TxnDate = "2016-10-19";

//Add customer
$customerRef2= new IPPReferenceType();
$customerRef2->value= "1";
$invoiceObj2->CustomerRef= $customerRef2;

//Create Line
$line2 = new IPPLine();
$line2->Amount= 1*90.84;
$Line2->Description = 'Test Product';

$linetype2= new IPPLineDetailTypeEnum();
$linetype2->value="SalesItemLineDetail";

$lineDetail2 = new IPPSalesItemLineDetail();
$lineDetail2->ItemRef = "4";
$lineDetail2->UnitPrice = 90.84;
$lineDetail2->Qty= 1;

$line2->DetailType=$linetype2;
$line2->SalesItemLineDetail=$lineDetail2;

$invoiceObj2->Line=$line2;

$resultingInvoiceObj2 = $dataService->Add($invoiceObj2);

echo "Created Invoice Id={$resultingInvoiceObj2->Id}. Reconstructed response body:<br/><br/>";
$xmlBody = XmlObjectSerializer::getPostXmlFromArbitraryEntity($resultingInvoiceObj2, $urlResource);
echo "<pre>";
echo $xmlBody . "<br/>";
echo "</pre>";