XML and JSON with #List
- 7 years ago
You have some error in syntax error code.
Please try this piece of code.
One more thing YOU endpoint must be of View Content Type : text/xml
Please see this screenshot: https://prnt.sc/ib0po2
You XML result should be like this : https://prnt.sc/ib0qko
<#assign datenow=.now?date?long>
<#assign daysinms = 1*24*60*60*1000>
<#assign datediff= datenow - daysinms>
<#assign x = rest("2.0","/search?q=" + "SELECT view_href, post_time, subject, board FROM messages WHERE replies.count(*)=0 AND depth=0 AND post_time > ${datediff} AND post_time < ${datenow} ORDER BY post_time ASC"?url) />
<#assign count= rest("2.0","/search?q=" + "SELECT count(*) FROM messages WHERE replies.count(*)=0 AND depth=0 AND post_time > ${datediff} AND post_time < ${datenow}"?url).data.count />
<#if count gt 0>
<response status="success">
<messages>
<#list x.data.items as message>
<message type="message" href="${message.view_href}"></message>
</#list>
</messages>
</response>
<#else>
<response status="error">
<error code="c001">
<message>No posts in last 24 hours</message>
</error>
</response>
</#if>