Forum Discussion

ChaviBonchev's avatar
ChaviBonchev
Khoros Alumni (Retired)
12 years ago

REST API call to check contest rating system type

When we're checking top kudoed messages within a contest:

.../restapi/vc/boards/id/<contest_node_id>/kudos/leaderboard/top-messages?page_size=3&max_age=all

It works as expected, but as soon as the contest admin changes the rating system type from kudos to 1-5 star rating, that same call starts to give "303 Permission Denied" error

It there's a way to check the rating system type or possible way to handle this error?

Thanks.

  • AdamN's avatar
    AdamN
    12 years ago

    Ah, thanks for clarifying. In that case, I believe the setting you're looking for is:

    contest.ratings.primary_type

     

    So putting it all together, you call might look something like:

    /boards/id/<CONTEST ID>/settings/name/contest.ratings.primary_type

     In the case of Kudos, your response will look like:

    <response status="success">
    <value type="string">kudos</value>
    </response>

     In the case of 1-5 stars, your response will look like:

    <response status="success">
    <value type="string">contest_ratings</value>
    </response>

     

     

  • AdamN's avatar
    AdamN
    Khoros Oracle

     

    There are REST API calls available to check the value of node settings. See more information here:

    http://lithosphere.lithium.com/t5/developers-discussion/REST-call-for-quot-Is-the-accepted-solutions-feature-enabled/m-p/81614#M2851

     

    In this case, has Kudos been turned off? If so, that should be pretty easy to check. The name of that setting is:

    config.enable_kudos - Turn on Kudos

     

    If that's set to true and you're still getting errors on the leaderboard, there are a couple of other settings you might be able to check:

    config.enable_ratings - Turn on Ratings

    ratings.supported_rating_types - Supported rating styles

     

    So once you've determined the necessary setting, you should be able to wrap your REST API call to check whether the setting has the proper value. I'm assuming it's just the Kudos one, but provided the others just in case. So you'd want to check that config.enable_kudos is set to true.

     

    Another thing you can do, if you're not already, is wrap your REST API calls in a FreeMarker attempt/recover block. This helps surpress the REST API error, allowing you to handle it more gracefully. More details here:

    http://freemarker.sourceforge.net/docs/ref_directive_attempt.html

    • ChaviBonchev's avatar
      ChaviBonchev
      Khoros Alumni (Retired)

      Thanks Adam, kudos are enabled and will stay enabled, but there is this option for contests in the contest admin:

      contest.png

      which, when set to '1-5 Star ratings' starts causing the kudos/leaderboard call to return "303 Permission Denied".

       

      The FreeMarker attempt/recover block is definitely an option we're going to check. Thanks!

       

      • AdamN's avatar
        AdamN
        Khoros Oracle

        Ah, thanks for clarifying. In that case, I believe the setting you're looking for is:

        contest.ratings.primary_type

         

        So putting it all together, you call might look something like:

        /boards/id/<CONTEST ID>/settings/name/contest.ratings.primary_type

         In the case of Kudos, your response will look like:

        <response status="success">
        <value type="string">kudos</value>
        </response>

         In the case of 1-5 stars, your response will look like:

        <response status="success">
        <value type="string">contest_ratings</value>
        </response>