Forum Discussion

nchungie's avatar
10 years ago

Cannot post a "not helpful" rating

I'm using this documentation as reference:

https://community.lithium.com/t5/Community-API/bd-p/developers-rest-api?leaf-id=Product.ratings.key.key#Product.ratings.key.key.ratings.add

 

Here is my angular resource code:

setHelpfulness: {
method: 'POST',
data : {
'restapi.session_key': sessionService.get('userSessionKey'),
'rating.value' : '@rating.value'
},
url: apiUrl + 'messages/id/:messageId/ratings/key/tkb_helpfulness/ratings/add'
}

 

When I post a "1" (for helpful) it works.

 

When I post a "-2" (for not helpful) based on this documentation: https://community.lithium.com/t5/Community-API/bd-p/developers-rest-api?branch=HelpfulnessRatingSummary, I get the following error:

 

{"response":{"status":"error","error":{"code":303,"message":"error.lithium.restapi.user_not_registered.body.body"}}}

 

I thought maybe I was just logged out, so I logged back in, but the error continues.

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)

    Hi nchungie 

     

    given that you seem to be passing documented value and you are getting a seemingly unrelated error back, the best course of action for you would be to raise this query with Lithium Support so that they can look at it in detail. It could be either a genuine bug or a mis-configuration of your instance.

     

    Hope it helps,

  • TedC's avatar
    TedC
    Lithium Alumni (Retired)

    Hello nchungie!

     

    Sorry for the confusion here. I took your example code snippet (thank you, by the way, it was very helpful) and I translated it to a sample REST API call that can be made via HTTP:

     

    http://test.lithium.example/restapi/vc/messages/id/155/ratings/key/tkb_helpfulness/ratings/add?rating.value=-2

     

    The above failed, which is also what you were encountering. So, I tried manipulating the integer and did some poking around - mso was very helpful in pointing out that in actuality, a "Yes"/"Helpful" response has a value of "1", and a "No"/"Unhelpful" response has a value of "0". The API documentation needs to be updated and we are working with our Docs team to update that to be accurate; I figured I'd respond in here so that you know what to use for your code.

     

    http://test.lithium.example/restapi/vc/messages/id/155/ratings/key/tkb_helpfulness/ratings/add?rating.value=0

     

    Hope this helps!

    Ted

     

    • I tried using "0" instead of "-2" several times.

       

      I get the same error:

       

      {"response":{"status":"error","error":{"code":303,"message":"error.lithium.restapi.user_not_registered.body.body"}}}
       
       
      Please see attached for my settings in the admin too.
       
      Screen Shot 2015-05-21 at 10.27.28 AM.png
      • TedC's avatar
        TedC
        Lithium Alumni (Retired)

        The 303 error code is something different than what we were encountering. Are you authenticated as a user with REST API permissions when executing the call to your community (from your application or from a normal browser)? The expected response should be a success, which is what we encountered when attempting to validate using the method in my previous post.