• Resolved yasirarafat

    (@yasirarafat)


    When requesting the product API, getting the following response:

    {
    “code”: “woocommerce_rest_cannot_view”,
    “message”: “Sorry, you cannot list resources.”,
    “data”: {
    “status”: 401
    }
    }

    The credentials are OK, it used to give response with the same credentials until yesterday. I tried with newly generated API keys, same problem.

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi, @yasirarafat!

    The response indicates that you are not authorized for that REST endpoint

    Please review the documentation once more, from here: https://woocommerce.github.io/woocommerce-rest-api-docs/#authentication

    .. and ensure that if you are using “Basic auth” that https is used for the connection, and that the user creating the REST API keys have both read/write permissions

    Cheers!

    Thread Starter yasirarafat

    (@yasirarafat)

    I already mentioned that the same credentials were working yesterday, and I tried with newly generated keys too. I am authorized for that REST endpoint, and the keys have both read/write permissions. I also tried with https for this site and https://www.justlive.com, but same problem for both. I also tried with http://woocommercedev.greatgift.ca, and http://aptwoocommerce.greatgift.ca, the API is not working for them, but is working for https://shop.moralcode.com.

    its doesnt worked for me too. i too get the same issue

    When requesting the product API, getting the following response:

    {
    “code”: “woocommerce_rest_cannot_view”,
    “message”: “Sorry, you cannot list resources.”,
    “data”: {
    “status”: 401
    }
    }

    Thread Starter yasirarafat

    (@yasirarafat)

    Hi @rynald0s,

    I found the reason of the issue. I’m using WooCommerce.Net, and it can’t deserialize the response of the WooCommerce API as it is sending PHP warning messages with the json:

    <b>Warning</b>: Declaration of WC_Shipping_Fedex::calculate_shipping($package) should be compatible with WC_Shipping_Method::calculate_shipping($package = Array) in <b>/nas/content/staging/justlive/wp-content/plugins/woocommerce-shipping-fedex/includes/class-wc-shipping-fedex.php</b> on line <b>1027</b><br />

    I posted the same issue 6 days ago, but nobody replied to the post yet:
    https://wordpress.org/support/topic/category-api-is-returning-php-warning-messages-with-the-json-response/

    Can you please stop sending the warning messages with the JSON response?

    @manigopal, Are you also using WooCommerce.Net?

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi, @yasirarafat!

    It sounds like you are using a super old version of the Fedex plugin — like pre-shipping zone support that was added in 2.6. If so, you’ll need to get the Fedex plugin up to a recent, compatible release, to resolve the issue. And, resolved issue = no warning with the JSON 😛

    Thread Starter yasirarafat

    (@yasirarafat)

    But, why you are sending PHP warnings with the json? Can’t you disable it?

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi, @yasirarafat!

    We don’t send any warnings with the JSON 😀 PHP warnings are being generated while the JSON is being generated — updating that plugin will resolve your issue.

    Cheers!

    Thread Starter yasirarafat

    (@yasirarafat)

    @rynald0s, I was getting the following warnings for the category API:

    <br />

    <b>Warning</b>: preg_match() expects parameter 2 to be string, object given in <b>/nas/content/staging/justlive/wp-includes/formatting.php</b> on line <b>1529</b><br />

    <br />

    <b>Warning</b>: strip_tags() expects parameter 1 to be string, object given in <b>/nas/content/staging/justlive/wp-includes/formatting.php</b> on line <b>1981</b><br />

    Are they also for the Fedex plugin?

    I deactivated the plugin from the site, but still can’t authenticate with WooCommerce.Net

    Plugin Support Stuart Duff – a11n

    (@stuartduff)

    Automattic Happiness Engineer

    WooCommerce.Net does not exist and the error messages you have posted do not contain any information which could help regrettably.

    Cross testing with the latest version of WooCommerce and the Postman API App to gain some comparison results the WooCommerce REST API for categories is fully accessible when testing on my installs.

    The official documentation for the WooCommerce REST API authentication and product categories can be found below.

    http://woocommerce.github.io/woocommerce-rest-api-docs/#authentication

    http://woocommerce.github.io/woocommerce-rest-api-docs/#product-categories

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘WooCommerce API is not working’ is closed to new replies.