aquiss 1 Posted January 1, 2020 I'm trying to use the CreateQuote (Curl Method) as shown https://developers.whmcs.com/api-reference/createquote/ I'm using the following test code <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'url snipped'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query( array( 'action' => 'CreateQuote', 'username' => '', 'password' => '', 'subject' => 'Test Quote Subject', 'stage' => 'Draft', 'validuntil' => '30/01/2020', 'lineitems' => base64_encode(serialize(array(array("desc"=>"Test Description 1","qty"=>1,"up"=>"10.00","discount"=>"10.00", "taxable"=>true),array("desc"=>"Test Description 2","qty"=>4,"up"=>"15.00","discount"=>"0.00", "taxable"=>false))));, 'responsetype' => 'json', ) ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); ?> However, I just can't get it working at all. Just seems to return an error. Docs don't mention any other Required elements, however, I'm getting an error saying it must be an array. However, the example code is being used exactly as given from the docs page. Error appearing in logs is: Error: TypeError: Argument 20 passed to saveQuote() must be of the type array, null given, called in /var/www/vhosts/snippedurl/httpdocs/includes/api/createquote.php on line 0 and defined in /var/www/vhosts/snippedurl/httpdocs/includes/quotefunctions.php:0 Stack trace: #0 /var/www/vhosts/snippedurl/httpdocs/includes/api/createquote.php(0): saveQuote('', 'Test Quote Subj...', 'Draft', '2019-12-31', '30/01/2020', 'new', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, '') #1 /var/www/vhosts/snippedurl/httpdocs/vendor/whmcs/whmcs-foundation/lib/Api/V1/Api.php(0): unknown() #2 /var/www/vhosts/snippedurl/httpdocs/vendor/whmcs/whmcs-foundation/lib/Api/V1/Api.php(0): WHMCS\Api\V1\Api->executeApiCall() #3 /var/www/vhosts/snippedurl/httpdocs/vendor/whmcs/whmcs-foundation/lib/Api/ApplicationSupport/Route/Middleware/HandleProcessor.php(0): WHMCS\Api\V1\Api->call() #4 /var/www/vhosts/snippedurl/httpdocs/vendor/whmcs/whmcs-foundation/lib/Api/ApplicationSupport/Route/Middleware/HandleProcessor.php(0): WHMCS\Api\ApplicationSupport\Route\Middleware\HandleProcessor->processV1Request(Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest)) #5 /var/www/vhosts/snippedurl/httpdocs/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/Strategy/DelegatingMiddlewareTrait.php(0): WHMCS\Api\ApplicationSupport\Route\Middleware\HandleProcessor->_process(Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest), Object(Middlewares\Utils\Delegate)) #6 /var/www/vhosts/snippedurl/httpdocs/vendor/middlewares/utils/src/Dispatcher.php(76): WHMCS\Api\ApplicationSupport\Route\Middleware\HandleProcessor->process(Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest), Object(Middlewares\Utils\Delegate)) #7 [internal function]: Middlewares\Utils\Dispatcher->Middlewares\Utils\{closure}(Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest)) #8 /var/www/vhosts/snippedurl/httpdocs/vendor/middlewares/utils/src/Delegate.php(31): call_user_func(Object(Closure), Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest)) #9 /var/www/vhosts/snippedurl/httpdocs/vendor/whmcs/whmcs-foundation/lib/Api/ApplicationSupport/Route/Middleware/ActionResponseFormat.php(0): Middlewares\Utils\Delegate->process(Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest)) #10 /var/www/vhosts/snippedurl/httpdocs/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/Strategy/AssumingMiddlewareTrait.php(0): WHMCS\Api\ApplicationSupport\Route\Middleware\ActionResponseFormat->_process(Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest), Object(Middlewares\Utils\Delegate)) #11 /var/www/vhosts/snippedurl/httpdocs/vendor/middlewares/utils/src/Dispatcher.php(76): WHMCS\Api\ApplicationSupport\Route\Middleware\ActionResponseFormat->process(Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest), Object(Middlewares\Utils\Delegate)) #12 [internal function]: Middlewares\Utils\Dispatcher->Middlewares\Utils\{closure}(Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest)) #13 /var/www/vhosts/snippedurl/httpdocs/vendor/middlewares/utils/src/Delegate.php(31): call_user_func(Object(Closure), Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest)) #14 /var/www/vhosts/snippedurl/httpdocs/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/Strategy/DelegatingMiddlewareTrait.php(0): Middlewares\Utils\Delegate->process(Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest)) #15 /var/www/vhosts/snippedurl/httpdocs/vendor/whmcs/whmcs-foundation/lib/Security/Middleware/Authorization.php(0): WHMCS\Security\Middleware\Authorization->delegateProcess(Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest), Object(Middlewares\Utils\Delegate)) #16 /var/www/vhosts/snippedurl/httpdocs/vendor/whmcs/whmcs-foundation/lib/Route/Middleware/AbstractProxyMiddleware.php(0): WHMCS\Security\Middleware\Authorization->process(Object(WHMCS\Api\ApplicationSupport\Http\ServerRequest), Object(Middlewares\Utils\Delegate)) snip ........ Any ideas, because all I can find online is someone having similar but admin side, but claimed to be fixed in 7.7.1? 0 Quote Share this post Link to post Share on other sites
Kian 316 Posted January 1, 2020 First off there's a syntax error in documentation and in your script 🤔 1 Quote Share this post Link to post Share on other sites
aquiss 1 Posted January 1, 2020 Thanks Kian, I'll raise a ticket with support as the docs need correcting. 0 Quote Share this post Link to post Share on other sites
aquiss 1 Posted January 1, 2020 WHMCS Support have confirmed the docs are incorrect and are getting them updated. In the meantime, this is correct: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://yourwhmcs.com/whmcs/includes/api.php'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query( array( 'action' => 'CreateQuote', // See https://developers.whmcs.com/api/authentication 'username' => 'USERNAME', 'password' => 'PASSWORD', 'subject' => 'Test Quote Subject', 'stage' => 'Draft', 'userid' => '1', 'validuntil' => '01/01/2016', 'lineitems' => base64_encode(serialize(array(array("desc"=>"Test Description 1","qty"=>1,"up"=>"10.00","discount"=>"10.00", "taxable"=>true),array("desc"=>"Test Description 2","qty"=>4,"up"=>"15.00","discount"=>"0.00","taxable"=>false)))), 'responsetype' => 'json', ) ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); 0 Quote Share this post Link to post Share on other sites
WHMCS Marcus 12 Posted January 2, 2020 I have submitted a case with our development team to get this resolved. As @Kian mentioned, the error is a syntax error with an erroneous semi-colon. 0 Quote Share this post Link to post Share on other sites