Nath
7 years agoGuide
Sort labels from restapi
Hi, i config 4 labels in admin with this order : test1, test2, test3, test4 and i use restapi for return my labels : /restapi/vc/boards/id/blog/labels but the order of result in XML is : test1, t...
- 7 years ago
API returns the sorted results as per their usage count instead of the order in the admin section. You can check the labels usage count(how many times a label added with any message). You will get test1 > test 4 > test 3> test 2. That's why you are getting the label 'test 2' in last.
Actually, API gets the labels from board's messages, not from the admin section. Even label is added in admin section but API does not return the label until it is not added to any message.
But you can sort it using Freemarker function
<#assign getLabels = rest("/boards/id/Learning_Quick_Answers/labels/").labels.label?sort_by("text") /> <#list getLabels as label> ${label.text} </#list>
It will print the labels in expected order
test 1, test 2, test 3, test 4