2015-04-17 65 views
1

請在下面錯誤地協助我: 2015-04-16 10:45:10 - D:\ projects \ QuickBooksv3-php-sdk-2.0.5 \ DataService \ DataService.php - 340 - CheckNullResponseAndThrowException - 響應空或空Quickbooks Php SDK - CheckNullResponseAndThrowException - 響應空或空

3天前,我已經成功地測試了快速書籍的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>"; 

敬請幫助指出我的錯誤。謝謝

回答

0

請更改使用沙盒QBO帳戶的基礎URL或使用生產令牌連接到現有的QBO帳戶。 你的問題可能與此有關的變化特徵https://developer.intuit.com/v2/blog/2014/10/24/intuit-developer-now-offers-quickbooks-sandboxes

您也可以嘗試改變的值,然後嘗試融入QB

+1

雖然此鏈接可以回答這個問題,最好是在這裏有答案的主要部件,並提供鏈接以供參考。如果鏈接頁面更改,則僅鏈接答案可能會失效。 –

0

我已經解決了同樣的問題,檢查要求PARAMS。請檢查必填字段。

必填字段至少是:

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>";