Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PUT request stopped working #292

Open
JavaBog opened this issue Jan 8, 2021 · 2 comments
Open

PUT request stopped working #292

JavaBog opened this issue Jan 8, 2021 · 2 comments

Comments

@JavaBog
Copy link

JavaBog commented Jan 8, 2021

PUT requests stopped working. GET requests work fine.
Receiving:
Fatal error: Uncaught Automattic\WooCommerce\HttpClient\HttpClientException: Syntax error in...

Code:

require(APP . '/lib/vendor/autoload.php');
use Automattic\WooCommerce\Client;
/*
$woocommerce = new Client(
    'https://xxx.com', 
    'xxx', 
    'xxx',
    [
        'wp_api' => true,
        'version' => 'wc/v3',
    ]
);


$data = [
		'status' => 'Completed'
	];
			
print_r($woocommerce->get('orders/xxx');
print_r($woocommerce->put('orders/xxx', $data));

@JavaBog
Copy link
Author

JavaBog commented Jan 8, 2021

Looks like PUT requests just stopped working

FIX:
Send as post and add PUT method to end point

Before:
print_r($woocommerce->put('orders/xxx', $data));
After:
print_r($woocommerce->post('orders/xxx?_method=PUT', $data));

@georgosabdulnour
Copy link

i stell have this error when use PUT to update product
Fatal error: Uncaught Automattic\WooCommerce\HttpClient\HttpClientException: Error: Ogiltiga parametrar: status [rest_invalid_param] in C:\xampp\htdocs\woo\vendor\automattic\woocommerce\src\WooCommerce\HttpClient\HttpClient.php:350 Stack trace: #0 C:\xampp\htdocs\woo\vendor\automattic\woocommerce\src\WooCommerce\HttpClient\HttpClient.php(386): Automattic\WooCommerce\HttpClient\HttpClient->lookForErrors(Object(stdClass)) #1 C:\xampp\htdocs\woo\vendor\automattic\woocommerce\src\WooCommerce\HttpClient\HttpClient.php(422): Automattic\WooCommerce\HttpClient\HttpClient->processResponse() #2 C:\xampp\htdocs\woo\vendor\automattic\woocommerce\src\WooCommerce\Client.php(56): Automattic\WooCommerce\HttpClient\HttpClient->request('orders/5777?_me...', 'POST', Array) #3 C:\xampp\htdocs\woo\product.php(21): Automattic\WooCommerce\Client->post('orders/5777?_me...', Array) #4 {main} thrown in C:\xampp\htdocs\woo\vendor\automattic\woocommerce\src\WooCommerce\HttpClient\HttpClient.php on line 350

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants