part of object missing when creating a Purchase Order Object for the Quickbooks php sdk -
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(e_all); require "vendor/autoload.php"; use quickbooksonline\api\core\servicecontext; use quickbooksonline\api\dataservice\dataservice; use quickbooksonline\api\facades\purchaseorder; use quickbooksonline\api\data\ipppurchaseorderitemlinedetail; use quickbooksonline\api\data\ippline; use quickbooksonline\api\data\ipppurchaseorder; use quickbooksonline\api\data\ipppurchase; //use quickbooksonline\api\data\ //$dataservice = dataservice::configure("sdk.config"); $dataservice = dataservice::configure(array( 'auth_mode' => 'oauth1', 'consumerkey' => "", 'consumersecret' => "", 'accesstokenkey' => "", 'accesstokensecret' => "", 'qborealmid' => "", 'baseurl' => "https://quickbooks.api.intuit.com/" )); $linedet = new ipppurchaseorderitemlinedetail(); $linedet->manpartnum = 1; $linedet->customerref = 1; $linedet->purchaseorderitemlinedetailex = 'hello'; $linedet->manuallyclosed = 0; $linedet->openqty = 3; $linedet->servicedate='7/25/2017'; $linedet->taxinclusiveamt=5; $linedet->discountrate=5; $linedet->discountamt=5; $linedet->salesitemlinedetailex='hello'; $linedet->classref=5; $linedet->ratepercent=5; $linedet->pricelevelref=5; $linedet->markupinfo='no'; $linedet->uomref=5; $linedet->itemaccountref=5; $linedet->inventorysiteref=5; $linedet->taxcoderef=5; $line = new ippline(); $line->id = 0; $line->description = 'test purchase order'; $line->amount = 2.00; $line->detailtype= 'itembasedexpenselinedetail'; //line.itembasedexpenselinedetail missing in request $line->itembasedexpenselinedetail = $linedet;//line.itembasedexpenselinedetail missing in request var_dump($linedet); echo "<br>"; $line->billablestatus = 'notbillable'; /* these part of $line obj, not $linedet object $line->itemref = '19'; $line->unitprice = '25'; $line->qty = '1'; */ $purchaseorder = new ipppurchaseorder(); $purchaseorder->line = $line; $purchaseorder->vendorref = 85; $purchaseorder->apaccountref = 1; $purchaseorder->totalamt = 200.00; echo "<br><br>"; $result = $dataservice->add($purchaseorder); //add purchase order if($dataservice->add($purchaseorder)) echo "complete<br>"; else echo "not complete<br>"; $companyinfo = $dataservice->getcompanyinfo(); $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"; echo "the intuit helper message is: intuiterrortype:{" . $error->getintuiterrortype() . "} intuiterrorcode:{" . $error->getintuiterrorcode() . "} intuiterrormessage:{" . $error->getintuiterrormessage() . "} intuiterrordetail:{" . $error->getintuiterrordetail() . "}"; } ?>
this code copied somewhere else , cant work because don't know i'm doing; tradition on site, probably.
here's response got:
the status code is: 400 helper message is: invalid auth/bad request (got 400, expected http/1.1 20x or redirect) response message is: required param missing, need supply required value apirequired parameter line.itembasedexpenselinedetail.itemref missing in request intuit helper message is: intuiterrortype:{validationfault} intuiterrorcode:{2020} intuiterrormessage:{required param missing, need supply required value api} intuiterrordetail:{required parameter line.itembasedexpenselinedetail.itemref missing in request}
error: creating purchase order in quickbook v3 php api
as question, read documentation , found sample object represents bare minimum amount of information can submit purchase order with:
sample request { "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 }
how create purchase order in quickbook v3 php api
^this copied code from. kept saying line.itembasedexpenselinedetail missing in request, printed out entire $linedet object var_dump() , made sure there no nulls:
object(quickbooksonline\api\data\ipppurchaseorderitemlinedetail)#26 (21) { ["manpartnum"]=> int(1) ["manuallyclosed"]=> int(0) ["openqty"]=> int(3) ["purchaseorderitemlinedetailex"]=> string(5) "hello" ["servicedate"]=> string(9) "7/25/2017" ["taxinclusiveamt"]=> int(5) ["discountrate"]=> int(5) ["discountamt"]=> int(5) ["salesitemlinedetailex"]=> string(5) "hello" ["itemref"]=> string(2) "19" ["classref"]=> int(5) ["unitprice"]=> string(2) "25" ["ratepercent"]=> int(5) ["pricelevelref"]=> int(5) ["markupinfo"]=> string(2) "no" ["qty"]=> string(1) "1" ["uomref"]=> int(5) ["itemaccountref"]=> int(5) ["inventorysiteref"]=> int(5) ["taxcoderef"]=> int(5) ["customerref"]=> int(1) }
sorry, dont know how print nicely. had filled in, values (itemref, unitpric, , qty) came wih error:
the status code is: 400 helper message is: invalid auth/bad request (got 400, expected http/1.1 20x or redirect) response message is: invalid reference idinvalid reference id : you're trying use has been made inactive. check fields accounts, customers, items, vendors or employees. intuit helper message is: intuiterrortype:{validationfault} intuiterrorcode:{2500} intuiterrormessage:{invalid reference id} intuiterrordetail:{invalid reference id : you're trying use has been made inactive. check fields accounts, customers, items, vendors or employees.}
so when take itemref, unitpric, , qty out of $linedet object , $line object, says itemref missing:
$linedet = new ipppurchaseorderitemlinedetail(); $linedet->manpartnum = 1; $linedet->customerref = 1; $linedet->purchaseorderitemlinedetailex = 'hello'; $linedet->manuallyclosed = 0; $linedet->openqty = 3; $linedet->servicedate='7/25/2017'; $linedet->taxinclusiveamt=5; $linedet->discountrate=5; $linedet->discountamt=5; $linedet->salesitemlinedetailex='hello'; $linedet->classref=5; $linedet->ratepercent=5; $linedet->pricelevelref=5; $linedet->markupinfo='no'; $linedet->uomref=5; $linedet->itemaccountref=5; $linedet->inventorysiteref=5; $linedet->taxcoderef=5; /* $linedet->itemref=5; $linedet->unitprice = '25'; $linedet->qty = '1'; */ $line = new ippline(); $line->id = 0; $line->description = 'test purchase order'; $line->amount = 2.00; $line->detailtype= 'itembasedexpenselinedetail'; //line.itembasedexpenselinedetail missing in request $line->itembasedexpenselinedetail = $linedet;//line.itembasedexpenselinedetail missing in request var_dump($linedet); echo "<br>"; $line->billablestatus = 'notbillable'; $line->itemref = '19'; $line->unitprice = '25'; $line->qty = '1'; $purchaseorder = new ipppurchaseorder(); $purchaseorder->line = $line; $purchaseorder->vendorref = 85; $purchaseorder->apaccountref = 1; $purchaseorder->totalamt = 200.00; echo "<br><br>"; $result = $dataservice->add($purchaseorder); //add purchase order if($dataservice->add($purchaseorder)) echo "complete<br>"; else echo "not complete<br>"; $companyinfo = $dataservice->getcompanyinfo(); $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"; echo "the intuit helper message is: intuiterrortype:{" . $error->getintuiterrortype() . "} intuiterrorcode:{" . $error->getintuiterrorcode() . "} intuiterrormessage:{" . $error->getintuiterrormessage() . "} intuiterrordetail:{" . $error->getintuiterrordetail() . "}"; } ?>
the status code is: 400 helper message is: invalid auth/bad request (got 400, expected http/1.1 20x or redirect) response message is: required param missing, need supply required value apirequired parameter line.itembasedexpenselinedetail.itemref missing in request intuit helper message is: intuiterrortype:{validationfault} intuiterrorcode:{2020} intuiterrormessage:{required param missing, need supply required value api} intuiterrordetail:{required parameter line.itembasedexpenselinedetail.itemref missing in request}
Comments
Post a Comment