質問

I have recently updated to the latest version of WooCommerce 2.1 which includes a new RESTful API. I don't have much experience with cURL or RESTful APIs but I thought I give it a play.

My site is sergedenimes.com and I have SSL set up on the server.

If I run curl https://sergedenimes.com/wc-api/v1 I get a nice long bit of json output like so:

{
   "store":{
      "name":"Serge DeNimes",
      "description":"Original, Urban T-Shirts Of The Highest Quality by Oliver Proudlock",
      "URL":"http:\/\/sergedenimes.com",
      "wc_version":"2.1.2",
      "routes":{
         "\/":{
            "supports":[
               "HEAD",
               "GET"
            ],
            "meta":{
               "self":"http:\/\/sergedenimes.com\/wc-api\/v1\/"
            }
         },
         "\/customers":{ etc.....

This suggests the api itself is working. However when I pass a request that uses authentication:

curl https://sergedenimes.com/wc-api/v1/orders -u my_key:my_secret

I get this in response:

{
   "errors":[
      {
         "code":"woocommerce_api_authentication_error",
         "message":"Consumer Key is missing"
      }
   ]
}

Is my syntax correct? I have set up my key and secret under the WP admin and passed in the values but it seems to think I'm not passing it with my request.

Any ideas?

役に立ちましたか?

解決

Make sure you have secure checkout option enabled under WooCommerce -> Settings -> Checkout. It will only use basic auth if you have that option enabled.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top