omygoodness
8 years agoMentor
Display results from Rest API call
I am trying to list all messages that have marked solutions like this:
<#-- Endpoint to serve all accepted solutions -->
<#assign apiVersion = "2.0"/>
<#assign x= rest(apiVersion, "/search/messages?filter=solvedThreads&solved=true") />
<searchContent>
<post>
<title>Subject goes here</title>
</post>
</searchContent>
If I go to:
https://mycommunity/restapi/vc/search/messages?filter=solvedThreads&solved=true
I get XML with all I need but now I would like to know how to assign message attributes like subject to <title> in my endpoint XML
Few hours later I found solution to display all posts with accepted solutions - in this case it is simple rest call but you can build whatever call you want.
If someone finds it useful I will be more then happy :)
<#assign accepted_solutions = rest('/search/messages?filter=solvedThreads&solved=true').messages.message />
<searchContent>
<#list accepted_solutions as main_message>
<post>
<url>${main_message.@view_href}</url>
<title>${main_message.subject}</title>
</post>
</#list>
</searchContent>In result you get code for endpoint which produce simple formatted XML file