REST API error “301 has moved”
-
Hello, I am trying to figure out the issue with REST API integration, to no avail.
My declaration is as follows:
//Initiate REST API $woocommerceAPI_prod = new Client( 'https://example.com', 'ck_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', [ 'wp_api' => true, 'version' => 'wc/v3', 'query_string_auth' => true, 'debug' => true, 'ssl_verify' => false ] );
All is fine and dandy until I try to launch an import of products, which returns as shown below. I would love to know the actual issue that is causing this. The same exact setup worked fine before, and I am afraid it has to do something with server settings themselves, as that is the only thing that was changed since then. Thanks in advance.
Errors: JSON ERROR: Syntax error Automattic\WooCommerce\HttpClient\HttpClientException Object ( [request:Automattic\WooCommerce\HttpClient\HttpClientException:private] => Automattic\WooCommerce\HttpClient\Request Object ( [url:Automattic\WooCommerce\HttpClient\Request:private] => https://example.com/wp-json/wc/v3/products?consumer_key=ck_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&consumer_secret=cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx [method:Automattic\WooCommerce\HttpClient\Request:private] => POST [parameters:Automattic\WooCommerce\HttpClient\Request:private] => Array ( [consumer_key] => ck_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx [consumer_secret] => cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ) [headers:Automattic\WooCommerce\HttpClient\Request:private] => Array ( [Accept] => application/json [User-Agent] => WooCommerce API Client-PHP/3.0.0 [Content-Type] => application/json;charset=utf-8 ) [body:Automattic\WooCommerce\HttpClient\Request:private] => {"name":"Nude ladiest","lang":"lv","status":"draft","description":"<h2><strong>POLKA DOTS WALLETS\u00a0<\/strong><\/h2>\n<p>\u201ePlayful, adventurous and unconventional. These are the main features of polka dot wallets. And what is their main mission? To brighten up your day! Just choose the one that catches your attention the most and entrust it with all your valuables. It will then guard them like an eye (dot) in your head.\u201c<\/p>","short_description":"<h2><strong>POLKA DOTS WALLETS\u00a0<\/strong><\/h2>\n<p>\u201ePlayful, adventurous and unconventional. These are the main features of polka dot wallets. And what is their main mission? To brighten up your day! Just choose the one that catches your attention the most and entrust it with all your valuables. It will then guard them like an eye (dot) in your head.\u201c<\/p>","type":"variable","sku":"8594198070003","regular_price":"14.94","manage_stock":true,"stock_quantity":"468","stock_status":"instock","backorders":"no","weight":"120","dimensions":{"length":"195","width":"90","height":"25"},"categories":[{"id":53}],"images":[{"src":"https:\/\/i00.eu\/img\/661\/1024x1024\/d4z4iksb\/4.jpg","name":"Nude ladiest","alt":"Nude ladiest"},{"src":"https:\/\/i00.eu\/img\/661\/1024x1024\/5fovt98i\/5.jpg","name":"Nude ladiest","alt":"Nude ladiest"},{"src":"https:\/\/i00.eu\/img\/661\/1024x1024\/hf349bgf\/6.jpg","name":"Nude ladiest","alt":"Nude ladiest"},{"src":"https:\/\/i00.eu\/img\/661\/1024x1024\/dbzp4ke5\/7.jpg","name":"Nude ladiest","alt":"Nude ladiest"},{"src":"https:\/\/i00.eu\/img\/661\/1024x1024\/30lgfjs4\/9.jpg","name":"Nude ladiest","alt":"Nude ladiest"},{"src":"https:\/\/i00.eu\/img\/661\/1024x1024\/1r64blv4\/11.jpg","name":"Nude ladiest","alt":"Nude ladiest"},{"src":"https:\/\/i00.eu\/img\/661\/1024x1024\/818wumij\/18141.jpg","name":"Nude ladiest","alt":"Nude ladiest"},{"src":"https:\/\/i00.eu\/img\/661\/1024x1024\/arm0zii8\/19581.jpg","name":"Nude ladiest","alt":"Nude ladiest"},{"src":"https:\/\/i00.eu\/img\/661\/1024x1024\/ora97umn\/19582.jpg","name":"Nude ladiest","alt":"Nude ladiest"}],"attributes":[{"id":1,"option":"Roz\u0101","variation":true,"visible":true},{"id":2,"option":"A4 izm\u0113r\u0101","visible":true},{"id":3,"option":"Dab\u012bg\u0101 \u0101da","visible":true}]} ) [response:Automattic\WooCommerce\HttpClient\HttpClientException:private] => Automattic\WooCommerce\HttpClient\Response Object ( [code:Automattic\WooCommerce\HttpClient\Response:private] => 301 [headers:Automattic\WooCommerce\HttpClient\Response:private] => Array ( [Server] => nginx [Date] => Fri, 02 Sep 2022 17:31:00 GMT [Content-Type] => text/html; charset=iso-8859-1 [Content-Length] => 380 [Connection] => keep-alive [Keep-Alive] => timeout=60 [Location] => https://www.example.com/wp-json/wc/v3/products?consumer_key=ck_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&consumer_secret=cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ) [body:Automattic\WooCommerce\HttpClient\Response:private] => Moved Permanently The document has moved here. ) [message:protected] => JSON ERROR: Syntax error [string:Exception:private] => [code:protected] => 301 [file:protected] => /home/example/web/example.com/public_html/wp-content/plugins/wu-import/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php [line:protected] => 379 [trace:Exception:private] => Array ( [0] => Array ( [file] => /home/example/web/example.com/public_html/wp-content/plugins/wu-import/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php [line] => 424 [function] => processResponse [class] => Automattic\WooCommerce\HttpClient\HttpClient [type] => -> ) [1] => Array ( [file] => /home/example/web/example.com/public_html/wp-content/plugins/wu-import/vendor/automattic/woocommerce/src/WooCommerce/Client.php [line] => 56 [function] => request [class] => Automattic\WooCommerce\HttpClient\HttpClient [type] => -> ) [2] => Array ( [file] => /home/example/web/example.com/public_html/wp-content/plugins/wu-import/wu-import.php [line] => 109 [function] => post [class] => Automattic\WooCommerce\Client [type] => -> ) [3] => Array ( [file] => /home/example/web/example.com/public_html/wp-content/plugins/wu-import/wu-import.php [line] => 62 [function] => wexp_admin_import ) [4] => Array ( [file] => /home/example/web/example.com/public_html/wp-includes/class-wp-hook.php [line] => 307 [function] => wexp_admin ) [5] => Array ( [file] => /home/example/web/example.com/public_html/wp-includes/class-wp-hook.php [line] => 331 [function] => apply_filters [class] => WP_Hook [type] => -> ) [6] => Array ( [file] => /home/example/web/example.com/public_html/wp-includes/plugin.php [line] => 476 [function] => do_action [class] => WP_Hook [type] => -> ) [7] => Array ( [file] => /home/example/web/example.com/public_html/wp-admin/admin.php [line] => 259 [function] => do_action ) ) [previous:Exception:private] => [xdebug_message] => ( ! ) Automattic\WooCommerce\HttpClient\HttpClientException: JSON ERROR: Syntax error in /home/example/web/example.com/public_html/wp-content/plugins/wu-import/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php on line 379 Call Stack #TimeMemoryFunctionLocation 10.0001375208{main}( ).../admin.php:0 21.214623495032do_action( $hook_name = 'toplevel_page_wexp' ).../admin.php:259 31.214623495408WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:476 41.214623495408WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:331 51.214623496536wexp_admin( '' ).../class-wp-hook.php:307 61.215023496904wexp_admin_import( $woocommerceAPI = class Automattic\WooCommerce\Client { public $http = class Automattic\WooCommerce\HttpClient\HttpClient { protected $ch = resource(237) of type (Unknown); protected $url = 'https://example.com/wp-json/wc/v3/'; protected $consumerKey = 'ck_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; protected $consumerSecret = 'cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; protected $options = class Automattic\WooCommerce\HttpClient\Options { ... }; private $request = class Automattic\WooCommerce\HttpClient\Request { ... }; private $response = class Automattic\WooCommerce\HttpClient\Response { ... }; private $responseHeaders = 'HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 301 Moved Permanently\r\nServer: nginx\r\nDate: Fri, 02 Sep 2022 17:31:00 GMT\r\nContent-Type: text/html; charset=iso-8859-1\r\nContent-Length: 380\r\nConnection: keep-alive\r\nKeep-Alive: timeout=60\r\nLocation: https://www.example.com/wp-json/wc/v3/products?consumer_key=ck_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&consumer_secret=cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n\r\n' } } ).../wu-import.php:62 71.215123500248Automattic\WooCommerce\Client->post( $endpoint = 'products', $data = ['name' => 'Nude ladiest', 'lang' => 'lv', 'status' => 'draft', 'description' => '<h2><strong>POLKA DOTS WALLETS </strong></h2>\n<p>„Playful, adventurous and unconventional. These are the main features of polka dot wallets. And what is their main mission? To brighten up your day! Just choose the one that catches your attention the most and entrust it with all your valuables. It will then guard them like an eye (dot) in your head.“</p>', 'short_description' => '<h2><strong>POLKA DOTS WALLETS </strong></h2>\n<p>„Playful, adventurous and unconventional. These are the main features of polka dot wallets. And what is their main mission? To brighten up your day! Just choose the one that catches your attention the most and entrust it with all your valuables. It will then guard them like an eye (dot) in your head.“</p>', 'type' => 'variable', 'sku' => '8594198070003', 'regular_price' => '14.94', 'manage_stock' => TRUE, 'stock_quantity' => '468', 'stock_status' => 'instock', 'backorders' => 'no', 'weight' => '120', 'dimensions' => ['length' => '195', 'width' => '90', 'height' => '25'], 'categories' => [0 => [...]], 'images' => [0 => [...], 1 => [...], 2 => [...], 3 => [...], 4 => [...], 5 => [...], 6 => [...], 7 => [...], 8 => [...]], 'attributes' => [0 => [...], 1 => [...], 2 => [...]]] ).../wu-import.php:109 81.215123500248Automattic\WooCommerce\HttpClient\HttpClient->request( $endpoint = 'products', $method = 'POST', $data = ['name' => 'Nude ladiest', 'lang' => 'lv', 'status' => 'draft', 'description' => '<h2><strong>POLKA DOTS WALLETS </strong></h2>\n<p>„Playful, adventurous and unconventional. These are the main features of polka dot wallets. And what is their main mission? To brighten up your day! Just choose the one that catches your attention the most and entrust it with all your valuables. It will then guard them like an eye (dot) in your head.“</p>', 'short_description' => '<h2><strong>POLKA DOTS WALLETS </strong></h2>\n<p>„Playful, adventurous and unconventional. These are the main features of polka dot wallets. And what is their main mission? To brighten up your day! Just choose the one that catches your attention the most and entrust it with all your valuables. It will then guard them like an eye (dot) in your head.“</p>', 'type' => 'variable', 'sku' => '8594198070003', 'regular_price' => '14.94', 'manage_stock' => TRUE, 'stock_quantity' => '468', 'stock_status' => 'instock', 'backorders' => 'no', 'weight' => '120', 'dimensions' => ['length' => '195', 'width' => '90', 'height' => '25'], 'categories' => [0 => [...]], 'images' => [0 => [...], 1 => [...], 2 => [...], 3 => [...], 4 => [...], 5 => [...], 6 => [...], 7 => [...], 8 => [...]], 'attributes' => [0 => [...], 1 => [...], 2 => [...]]], $parameters = ??? ).../Client.php:56 91.246023528024Automattic\WooCommerce\HttpClient\HttpClient->processResponse( ).../HttpClient.php:424 )
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘REST API error “301 has moved”’ is closed to new replies.