I'm trying to create purchase orders using Quickbooks PHP SDK and keep getting an invalid/missing param error or possibly wrong ID.
My parameters are based off of the Quickbooks API Explorer. Under the Purchase Order's 'Create' demo, there's an option to generate some default json/xml. I thought this would give me the minimum required params.
So in my code, I have created a Purchase Order array with these Params and made up values. But can't figure out what is wrong or missing.
The few samples of PHP QuickBooks SDK Purchase orders I've seen are using Oauth 1.0, so playing with them was not worth my time since My APP uses Oauth 2.0
ERROR
The Status code is: 400 The Helper message is: Invalid auth/bad request strong text(got a 400, expected HTTP/1.1 20X or a redirect) The Response message is: Invalid Reference IdInvalid Reference Id : Something you're trying to use has been made inactive. Check the fields with accounts, customers, items, vendors or employees.
SAMPLE JSON from QUICKBOOKS API Explorer (data from App sandbox)
{
"Line": [{
"Id": "1",
"Amount": 25.0,
"DetailType": "ItemBasedExpenseLineDetail",
"ItemBasedExpenseLineDetail": {
"CustomerRef": {
"value": "3",
"name": "Cool Cars"
},
"BillableStatus": "NotBillable",
"ItemRef": {
"value": "38",
"name": "Garden Supplies"
},
"UnitPrice": 25,
"Qty": 1,
"TaxCodeRef": {
"value": "NON"
}
}
}],
"VendorRef": {
"value": "41",
"name": "Hicks Hardware"
},
"APAccountRef": {
"value": "33",
"name": "Accounts Payable (A/P)"
},
"TotalAmt": 25.0
}
Quickbooks.php (only the important parts)
$purchaseOrder = PurchaseOrder::create([
"Line" =>[
[
"Id" =>"0",
"Amount" => 25.0,
"DetailType" => "ItemBasedExpenseLineDetail",
"ItemBasedExpenseLineDetail"=>
[
"CustomerRef"=>
[
"value"=>"3",
"name"=>"Cool Cars"
],
"BillableStatus"=> "NotBillable",
"ItemRef"=>
[
"value"=> "38",
"name"=> "Garden Supplies"
],
"UnitPrice"=> "25",
"Qty"=>"1",
"TaxCodeRef"=>
[
"value"=> "NON",
]
]
]
],
"VendorRef"=>
[
"value"=>"41",
"name"=>"Hicks Hardware"
],
"APAccountRef"=>
[
"value"=>"33",
"name"=>"Accounts Payable (A/P)"
],
"TotalAmt"=> 25.0
]);
$resultingpurchaseOrder = $dataService->Add($purchaseOrder);
$error = $dataService->getLastError();
if ($error != null) {
echo "The Status code is: " . $error->getHttpStatusCode() . "\n";
echo "The Helper message is: " . $error->getOAuthHelperError() . "\n";
echo "The Response message is: " . $error->getResponseBody() . "\n";
} else {
var_dump($resultingpurchaseOrder);
}