Forum Discussion

cike's avatar
cike
Champion
7 years ago

Same API call - different results

Hi there,

currently I'm facing a strange thing using Lithium APIv1. I set up two different endpoints and each of them makes this API call:

<#assign roles = restadmin("/users/id/${uid}/roles").roles />

My test user has 4 roles assigned. One of my endpoints returns the correct 4 values. But the other one returns a list size of only 1 and the response can't be looped with freemarker.

I also tried to use hard-coded uid values, but the result is still the same.

 

***Update***

When sending the same API call from a custom component, I also get the correct dataset in response. Seems that only the specific endpoint run into this problem.

 

Has anyone faced a similar issue in the past or has some ideas/hints what went wrong here?

 

Thanks and best regards,

Christian

  • Hi jaread83

    In order to obtain the most popular labels the API v2 labels would need to support both GROUP BY and SORT, which unfortunately they don't yet.

     

    But there is some good news: You might actually not need to create a custom component. Take a look at the Lithium Studio documentation of the updated responsive labels widget labels.widget.labels-list as it allows for sorting and limiting the output to 5 labels as well:

2 Replies

  • cike

    Give a try to this code.

    <#assign roles = restadmin("/users/id/${uid?c}/roles").roles />

    If it doesn't' work for you then share your endpoint code over here for free marker list as well.

     

  • cike's avatar
    cike
    Champion
    7 years ago

    Parshant - Thanks for your reply.  The "?c" operator did not work in this case, because my uid is already a string.

    After some deeper investigation and rebuilding my endpoint step by step I found the cause of this issue: It was a simple and small typo. :smileyvery-happy: