alinaalam on "Can't access products using WooCommerce API"

ساخت وبلاگ

alinaalam
Member
Posted 9 hours ago #

Hi!

I am trying to get a list of orders placed by the users using woocommerce Rest API. I have successfully done the following steps:

1) Enable pretty permalinks on the website
2) Enable REST API option in Woocommerce Settings
3) Generate Keys to get consumer key and consumer secret key

Everytime, I try to access the woocommerce api, I get a 404 error. I am not sure why this is happening!

Regards,

https://wordpress.org/plugins/woocommerce/

What call are you using to access the API?

alinaalam
Member
Posted 8 hours ago #

Hi Mike!

Thanks for the quick reply. I am trying to access the API like this:
https://www.gms-automation.com/gms/wc-api/v3/orders?consumer_key=xxx&consumer_secret=xxx

I am using actual credentials instead of *xxx*

It doesn't work like that, See the section on authentication https://woothemes.github.io/woocommerce-rest-api-docs/#authentication

alinaalam
Member
Posted 8 hours ago #

I used the API in the same way in another website and it worked without any issue!

@alinaalam this is not a 404 error. You do not have a valid SSL certificate on your site.

alinaalam
Member
Posted 3 minutes ago #

Hi Claudio!

After spending an entire day on this, I finally managed to narrow down the problem to this particular error:

Invalid URL, no WC API found at http://www.gsm-automation.com/gsm/wc-api/v2/ -- ensure your store URL is correct and pretty permalinks are enabled. 404

I am using Woocommerce Rest Api library and I was getting an invalid JSON error. When i set the 'validate_url' parameter to true, the library retued this error. As already mentioned, I have enabled pretty permalinks and I don't know what else to do with my site URL because this IS the url!

Also, I am sending an HTTP request so I have used all the parameters as mentioned in the documentation. I get this reply when i set 'validate_url' to false:

`Invalid JSON retued for http://www.gsm-automation.com/gsm/wc-api/v2/orders?oauth_consumer_key=ck_1c6786d01a5a7e74653724dabe082d0a5a1d6a58&oauth_timestamp=1463164149&oauth_nonce=725559d6c22df92f247214966a55fc0f57f99e33&oauth_signature_method=HMAC-SHA256&oauth_signature=OVuXBbHmVEzOVYeJ4xanlb7ByXrmHlb7%2BFPWQkvPyjw%3D.
0
stdClass Object
(
[headers] => Array
(
[0] => Accept: application/json
[1] => Content-Type: application/json
[2] => User-Agent: WooCommerce API Client-PHP/2.0.1
)

[method] => GET
[url] => http://www.gsm-automation.com/gsm/wc-api/v2/orders?oauth_consumer_key=ck_1c6786d01a5a7e74653724dabe082d0a5a1d6a58&oauth_timestamp=1463164149&oauth_nonce=725559d6c22df92f247214966a55fc0f57f99e33&oauth_signature_method=HMAC-SHA256&oauth_signature=OVuXBbHmVEzOVYeJ4xanlb7ByXrmHlb7%2BFPWQkvPyjw%3D
[params] => Array
(
[oauth_consumer_key] => ck_1c6786d01a5a7e74653724dabe082d0a5a1d6a58
[oauth_timestamp] => 1463164149
[oauth_nonce] => 725559d6c22df92f247214966a55fc0f57f99e33
[oauth_signature_method] => HMAC-SHA256
[oauth_signature] => OVuXBbHmVEzOVYeJ4xanlb7ByXrmHlb7+FPWQkvPyjw=
)

[data] => Array
(
)

[body] =>
[duration] => 0.67395
)
stdClass Object
(
[body] =>
[code] => 0
[headers] => Array
(
)

)

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 231 تاريخ : شنبه 25 ارديبهشت 1395 ساعت: 1:46