JSON Error try get products API
-
Hello! I am making a php script with the Woocommerce API that through the SKU I want to filter the products in the first instance it works and brings me the first 100 products.
$products = $woocommerce->get(‘products’,array(‘per_page’ => 100,’page’ =>1, ‘sku’ => $param_sku));
Then I want to see the next 100 products on page 2 but it doesn’t work, this code used to work very well but today it gives me this error. I have 338 products page 1 and 4 work well but 2 and 3 give me an error.
$products = $woocommerce->get(‘products’,array(‘per_page’ => 100,’page’ =>2, ‘sku’ => $param_sku));
Fatal error: Uncaught Automattic\WooCommerce\HttpClient\HttpClientException: JSON ERROR: Syntax error in /home/customer/www/miweb.com/public_html/rest/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php:378 Stack trace: #0 /home/customer/www/miweb.com/public_html/rest/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php(422): Automattic\WooCommerce\HttpClient\HttpClient->processResponse() #1 /home/customer/www/miweb.com/public_html/rest/vendor/automattic/woocommerce/src/WooCommerce/Client.php(82): Automattic\WooCommerce\HttpClient\HttpClient->request(‘products’, ‘GET’, Array, Array) #2 /home/customer/www/miweb.com/public_html/rest/index2.php(33): Automattic\WooCommerce\Client->get(‘products’, Array) #3 {main} thrown in /home/customer/www/miweb.com/public_html/rest/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php on line 378
- The topic ‘JSON Error try get products API’ is closed to new replies.