Search code examples
woocommerce-rest-api

woocommerce REST API rating for a product id


I'm having a peculiar problem. I've setup woocommerce REST API and so far everything functions well, including when i'm making a review for a product. The problem is when I try to retrieve the review back, it always says 'Invalid review ID'

To make it clear, when I do this REST command it works well, listing all the reviews i created before /wp-json/wc/v3/products/reviews/

however when i do /wp-json/wc/v3/products/reviews/[product ID]

it will show the above mentioned 'Invalid review ID'

Tried combination with review ID itself, product ID, nothing worked.


Solution

  • To get all reviews for product based on product id in woocommerce v3 API you need to call this endpoint:

    /wp-json/wc/v3/products/reviews?product=ID
    

    So you need to pass product ID as URL parameter. To get all reviews for product with id 15 you need to send request like this:

    /wp-json/wc/v3/products/reviews?product=15