Ready to get started?Download WordPress


WooCommerce - excelling eCommerce
[resolved] Fetching customers in Woocommerce API throws error (4 posts)

  1. kishanmd
    Posted 1 year ago #

    The API works perfectly for getting orders and products, but when I try to get customer information I get the following error:

    {"errors":[{"code":"woocommerce_api_user_cannot_read_customer","message":"You do not have permission to read this customer"}]}

    I then added the permission to the user (list_users), but that results in the API breaking:

    Status 500 Internal Server Error
    Response does not contain any data.

    This is the response on every API call after I add the list_users permission. When I revoke this, every API call but /customers/ works again.

    Do I need to add more permissions for the user? Or is this a bug in the API?


  2. Daniel Espinoza
    Posted 1 year ago #

    This is a server side error. Check your server's PHP log and see if there are more details to the error. Post that here for some assistance.

  3. kishanmd
    Posted 1 year ago #

    Hi Daniel,

    I checked my logs, it appears to have something to do with fetching a user's avatar:

    [Fri Feb 21 13:41:18 2014] [error] PHP Warning:  DOMDocument::loadHTML(): Empty string supplied as input in /var/www/goudenschaar/goudenschaar/wp-content/plugins/woocommerce/includes/api/class-wc-api-customers.php on line 428
    [Fri Feb 21 13:41:18 2014] [error] PHP Fatal error:  Call to a member function getAttribute() on a non-object in /var/www/goudenschaar/goudenschaar/wp-content/plugins/woocommerce/includes/api/class-wc-api-customers.php on line 430

    Mind you, avatars aren't being used by me.


  4. kishanmd
    Posted 1 year ago #

    I managed to fix it, the avatar_url was being checked through passing the customer_email to the get_avatar_url function. But I only use billing_email in my system (customer_email doesn't exist in the db), which is why there's an empty string passed to the get_avatar_url function.

    I fixed it temporarily by bypassing the get_avatar_url function, and setting the avatar_url key in the array to value 'null'.

    Thanks for getting back to me, marked as solved.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic