joflo64
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] REST API Order Update request getting 400 error (Bad Request)An update… …it appears the problem is in Cloudflare !
I was given permissions to log in as an Admin on teh clients WooCommerce site. After installing the API Log plugin I could see that the offending PUT requests from our php server, was not reaching the woo/wordpress API and therefore cloudflare is indeed rejecting the request.
When sent from the webbrowser plugin in or via the o.s command line and cURL utility the PUT request will get past Cloudflare and reach Woo !
As I don’t have access to our client’s Cloufdflare account they will be investigating why the PUT from our server is rejected.
Hopefully they will get to the bottom of this and I’ll update this thread.
Thank you all again for your suggestions to date .
Cheers.
Forum: Plugins
In reply to: [WooCommerce] REST API Order Update request getting 400 error (Bad Request)Thank you both for your responses.
I hope to get access to the client’s server and have access to an “Admin” account in Woo so I can go through these suggestions.
Of Note: I used a browser plugin to run the “raw” REST request against the target domain and suprise the request went through with the order being updated as expected ????
So that adds some confusion to the mix. The php code that generates the request uses the native cURL library. After stepping through the code and examining variables it looks like parameters are set as expected, so again more confusion 🙁
I intend to create a quick script (php) so I can examine what values headers , body etc is actually sent, I’ll post results.
In the mean time any other suggestions would appreciated.
Thanks.
Forum: Plugins
In reply to: [WooCommerce] REST API Order Update request getting 400 error (Bad Request)Thank you so much for your response to answer your questions
- V2 is used only as this integration was written sometime ago, as mentioned we have many other request working just fine so have not updated, though it may be time review that !
- The request is a PUT request, I have confirmed using visual studio runtime debug that the cURL request is setup correctly to send the data/parameters/headers —
- The body sent is definitely correct :- {“status”:”completed”}
- Headers specifically set and sent “Content-Type: application/json” “Content-Length: 22”
- URL is as described previously
- Can you suggest which log to look into there are many of them. I performed a “search” from the logs admin screen and no 400 error or other relevant strings was found in them . In some google searches people say to switch on API logging BUT I see no way of doing that in the admin / REST API screen ??
raw response is –
<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>cloudflare</center>
</body>
</html>Any tips on debugging would be great I’m not a woocommerce admin specialist ! Are there specific cURL settings needed/not needed for example ?
Language used is php 7.4 tested on both windows and Linux machines with the same result.
Forum: Plugins
In reply to: [WooCommerce] REST API Order Update request getting 400 error (Bad Request)Sorry updated question below due to bad copy/paste !!
Hi
We have the Rest API integration working for our client, numerous requests work without issue however when trying to update the status to “completed” (the orders are already in processing status) I always get a https status code of 400, the curl raw response is a HTML 400 bad requests page. The request end point and body look correct :-
URL :https://<domain>.com/wp-json/wc/v2/orders/111827?consumer_key=<key>&consumer_secret=<secret>
Body : “body”:”{“status”:”completed”}
The Added Rest API has correct permissions Read/Write.
On my localhost test instance the same request (different Order ID of course) works without any issues.
Any help here from what the issue could be to how to help debug the API request on the server would be greatly appreciated as I am stumped !
Thanks