Forum Discussion

wpigoury's avatar
wpigoury
Mentor
12 years ago

REST API author leaderboard

Hi,

 

I can't use this API call from within a custom component:

/restapi/vc/kudos/authors/leaderboard?max_age=all&page_size=5&restapi.response_style=view

 

When I load the url directly in the browser I get the user list as expected but when I try to get this list in my component with the rest() method it's always empty.

I get no errors, just an empty list even when I try with restadmin().

 

The result is the same whether I'm in the homepage, a category or in a board.

There are indeed kudoed authors on the community and the default author leaderboard component is working just fine.

 

Every other API calls I use are working.

 

I really don't understand why this one is giving me such a hard time.

 

Any idea?

4 Replies

  • I get the same result with every kudos calls except /kudos/count:

    - kudos/givers/leaderboard > ok in browser but empty in component
    - kudos/leaderboard/top-messages > ok in browser but empty in component
    - kudos/messages/leaderboard > ok in browser but empty in component

  • AdamN's avatar
    AdamN
    Khoros Oracle
    12 years ago

    Hi wpigoury,

     

    The call looks ok to me, and if it's working in your brower then it should be fine. Perhaps the issue isn't with the call, but rather the display of the content? Are you able to share a snippet of your code showing how you're assigning and iterating through the response?

     

    Here's quick sample I tested that should work for what you're trying to do:

    <#assign leaderBoard = rest("/kudos/authors/leaderboard?max_age=all&page_size=5").users />
    <ul>
    <#list leaderBoard.user as kudoUser>
    <li>${kudoUser.login} - ${kudoUser.mixin.kudos.weight}</li>
    </#list>
    </ul>

     

  • wpigoury's avatar
    wpigoury
    Mentor
    12 years ago
    Sorry, wrong copy/paste I left users instead of user in the list (<#list leaderboard.users...).
    I feel dumb :(
  • AdamN's avatar
    AdamN
    Khoros Oracle
    12 years ago

    No worries, it happens to the best of us! Glad you were able to get it working!