woocommerce REST API rating for a product id










0















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.










share|improve this question




























    0















    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.










    share|improve this question


























      0












      0








      0








      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.










      share|improve this question
















      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.







      woocommerce-rest-api






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 16:54







      chilly

















      asked Nov 15 '18 at 10:17









      chillychilly

      355




      355






















          2 Answers
          2






          active

          oldest

          votes


















          0














          Actually after half a day of tinkering, it turns out I had an extra parameter from the GET request.



          I did a /wp-json/wc/v3/products/reviews/[reviewID]?id=xx&otherparameters



          This causes the JSON rest to not detecting properly



          Hope this helps someone.






          share|improve this answer






























            0














            The problem is that you think the id is the product_id but it is review_id:



            /wp-json/wc/v3/products/reviews/[review ID] // it should end with review id



            If you want to retrieve all reviews of a specific product you should use this endpoint:



            'products/product_id/reviews'



            for example in ionic angular you can do this (using v2 rest api):



            this.WooCommerce = WC(
            url: "https://example.com",
            consumerKey: "ck_b#####################",
            consumerSecret: "cs_########################",
            wpAPI: true,
            version: 'wc/v2'
            )

            this.WooCommerce.getAsync('products/'+product_id+'/reviews').then((data)=>
            console.log(JSON.parse(data.body))
            this.reviews = JSON.parse(data.body);
            console.log(this.reviews); // logging reviews to console

            , (err)=>
            console.log(err);
            )





            share|improve this answer

























            • 'products/product_id/reviews' this results in 404

              – Rajesh Vishnani
              Jan 2 at 17:05






            • 1





              Ok @RajeshVishnani, You should use v2 version of rest api to use this endpoint. I will edit my post. Thanks

              – Hamid Araghi
              Jan 3 at 8:47










            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53317134%2fwoocommerce-rest-api-rating-for-a-product-id%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Actually after half a day of tinkering, it turns out I had an extra parameter from the GET request.



            I did a /wp-json/wc/v3/products/reviews/[reviewID]?id=xx&otherparameters



            This causes the JSON rest to not detecting properly



            Hope this helps someone.






            share|improve this answer



























              0














              Actually after half a day of tinkering, it turns out I had an extra parameter from the GET request.



              I did a /wp-json/wc/v3/products/reviews/[reviewID]?id=xx&otherparameters



              This causes the JSON rest to not detecting properly



              Hope this helps someone.






              share|improve this answer

























                0












                0








                0







                Actually after half a day of tinkering, it turns out I had an extra parameter from the GET request.



                I did a /wp-json/wc/v3/products/reviews/[reviewID]?id=xx&otherparameters



                This causes the JSON rest to not detecting properly



                Hope this helps someone.






                share|improve this answer













                Actually after half a day of tinkering, it turns out I had an extra parameter from the GET request.



                I did a /wp-json/wc/v3/products/reviews/[reviewID]?id=xx&otherparameters



                This causes the JSON rest to not detecting properly



                Hope this helps someone.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 15 '18 at 16:54









                chillychilly

                355




                355























                    0














                    The problem is that you think the id is the product_id but it is review_id:



                    /wp-json/wc/v3/products/reviews/[review ID] // it should end with review id



                    If you want to retrieve all reviews of a specific product you should use this endpoint:



                    'products/product_id/reviews'



                    for example in ionic angular you can do this (using v2 rest api):



                    this.WooCommerce = WC(
                    url: "https://example.com",
                    consumerKey: "ck_b#####################",
                    consumerSecret: "cs_########################",
                    wpAPI: true,
                    version: 'wc/v2'
                    )

                    this.WooCommerce.getAsync('products/'+product_id+'/reviews').then((data)=>
                    console.log(JSON.parse(data.body))
                    this.reviews = JSON.parse(data.body);
                    console.log(this.reviews); // logging reviews to console

                    , (err)=>
                    console.log(err);
                    )





                    share|improve this answer

























                    • 'products/product_id/reviews' this results in 404

                      – Rajesh Vishnani
                      Jan 2 at 17:05






                    • 1





                      Ok @RajeshVishnani, You should use v2 version of rest api to use this endpoint. I will edit my post. Thanks

                      – Hamid Araghi
                      Jan 3 at 8:47















                    0














                    The problem is that you think the id is the product_id but it is review_id:



                    /wp-json/wc/v3/products/reviews/[review ID] // it should end with review id



                    If you want to retrieve all reviews of a specific product you should use this endpoint:



                    'products/product_id/reviews'



                    for example in ionic angular you can do this (using v2 rest api):



                    this.WooCommerce = WC(
                    url: "https://example.com",
                    consumerKey: "ck_b#####################",
                    consumerSecret: "cs_########################",
                    wpAPI: true,
                    version: 'wc/v2'
                    )

                    this.WooCommerce.getAsync('products/'+product_id+'/reviews').then((data)=>
                    console.log(JSON.parse(data.body))
                    this.reviews = JSON.parse(data.body);
                    console.log(this.reviews); // logging reviews to console

                    , (err)=>
                    console.log(err);
                    )





                    share|improve this answer

























                    • 'products/product_id/reviews' this results in 404

                      – Rajesh Vishnani
                      Jan 2 at 17:05






                    • 1





                      Ok @RajeshVishnani, You should use v2 version of rest api to use this endpoint. I will edit my post. Thanks

                      – Hamid Araghi
                      Jan 3 at 8:47













                    0












                    0








                    0







                    The problem is that you think the id is the product_id but it is review_id:



                    /wp-json/wc/v3/products/reviews/[review ID] // it should end with review id



                    If you want to retrieve all reviews of a specific product you should use this endpoint:



                    'products/product_id/reviews'



                    for example in ionic angular you can do this (using v2 rest api):



                    this.WooCommerce = WC(
                    url: "https://example.com",
                    consumerKey: "ck_b#####################",
                    consumerSecret: "cs_########################",
                    wpAPI: true,
                    version: 'wc/v2'
                    )

                    this.WooCommerce.getAsync('products/'+product_id+'/reviews').then((data)=>
                    console.log(JSON.parse(data.body))
                    this.reviews = JSON.parse(data.body);
                    console.log(this.reviews); // logging reviews to console

                    , (err)=>
                    console.log(err);
                    )





                    share|improve this answer















                    The problem is that you think the id is the product_id but it is review_id:



                    /wp-json/wc/v3/products/reviews/[review ID] // it should end with review id



                    If you want to retrieve all reviews of a specific product you should use this endpoint:



                    'products/product_id/reviews'



                    for example in ionic angular you can do this (using v2 rest api):



                    this.WooCommerce = WC(
                    url: "https://example.com",
                    consumerKey: "ck_b#####################",
                    consumerSecret: "cs_########################",
                    wpAPI: true,
                    version: 'wc/v2'
                    )

                    this.WooCommerce.getAsync('products/'+product_id+'/reviews').then((data)=>
                    console.log(JSON.parse(data.body))
                    this.reviews = JSON.parse(data.body);
                    console.log(this.reviews); // logging reviews to console

                    , (err)=>
                    console.log(err);
                    )






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jan 3 at 8:52

























                    answered Dec 26 '18 at 19:01









                    Hamid AraghiHamid Araghi

                    297




                    297












                    • 'products/product_id/reviews' this results in 404

                      – Rajesh Vishnani
                      Jan 2 at 17:05






                    • 1





                      Ok @RajeshVishnani, You should use v2 version of rest api to use this endpoint. I will edit my post. Thanks

                      – Hamid Araghi
                      Jan 3 at 8:47

















                    • 'products/product_id/reviews' this results in 404

                      – Rajesh Vishnani
                      Jan 2 at 17:05






                    • 1





                      Ok @RajeshVishnani, You should use v2 version of rest api to use this endpoint. I will edit my post. Thanks

                      – Hamid Araghi
                      Jan 3 at 8:47
















                    'products/product_id/reviews' this results in 404

                    – Rajesh Vishnani
                    Jan 2 at 17:05





                    'products/product_id/reviews' this results in 404

                    – Rajesh Vishnani
                    Jan 2 at 17:05




                    1




                    1





                    Ok @RajeshVishnani, You should use v2 version of rest api to use this endpoint. I will edit my post. Thanks

                    – Hamid Araghi
                    Jan 3 at 8:47





                    Ok @RajeshVishnani, You should use v2 version of rest api to use this endpoint. I will edit my post. Thanks

                    – Hamid Araghi
                    Jan 3 at 8:47

















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53317134%2fwoocommerce-rest-api-rating-for-a-product-id%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3

                    Museum of Modern and Contemporary Art of Trento and Rovereto