I’m getting a JSON Syntax Error whenever I want to send any request to my WordPress site.
$woocommerce = new Client(
$site,
$key,
$secret,
[
'wp_api' => true,
'version' => 'wc/v3',
'query_string_auth' => true,
]
);
print_r($woocommerce->get('products'));
And when I run the function, I simply get:
AutomatticWooCommerceHttpClientHttpClientException
JSON ERROR: Syntax error
I dont know if there’s a way to get more info about the error, cause it’s not really explicit.
4
Answers
In the end, the problem came from the URL. Added "www" made the API call work. No documentation about this, the error only saying JSON Syntax Error, was nice clues to find a solution.
Solution : Just change default settings for permalink in wp-admin/options-permalink.php
Check if your URL($site) has ‘https://’