W
W
Wickep2019-09-20 07:16:43
WordPress
Wickep, 2019-09-20 07:16:43

Why does it give an error: Operation timed out on POST request?

There is a similar code:

require __DIR__ . '/vendor/autoload.php';

use Automattic\WooCommerce\Client;

$woocommerce = new Client(
    'https://example.com', 
    'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 
    'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    [
        'version' => 'wc/v3',
        'query_string_auth' => true
    ]
);

$result = $woocommerce->post('products', [ 'name' => 'Woo Single' ]);
print_r($result);

After its execution, a PHP Fatal error occurs during a POST request: Uncaught Automattic\WooCommerce\HttpClient\HttpClientException: cURL Error: Operation timed out...
But if you access the woo API via get or delete, then the requests are processed correctly:
$result = $woocommerce->get('products');
print_r($result);

Above code will return a list of all products in the store.
The question is why when a POST request is made through a script, timed out occurs.
I tried to create requests to the server through postman, everything works out as it should.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Developer, 2019-09-20
@samodum

This is a backend question.
It is necessary to look at the implementation of processing incoming POST requests.
Send the server code, let's see what hangs there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question