Getting a 500 server error with a custom endpoint
Hi all,
I've set up a custom endpoint which is trying to list out attachments to images. However whenever I try to use the result of the query it will cause a 500 error on the server.
Obviously I'm doing something wrong.
We raised a support ticket, but they don't provide support for custom end points. So I'm hoping the collective mind can help out.
The proof of concept code which causes the error is shown below.
<#setting url_escaping_charset='ISO-8859-1'> <#if user.registered > <#assign show_module = false /> <#list restadmin("/users/id/${user.id?c}/roles").roles.role as role> <#if role.name?? && (role.name == "Administrator")> <#assign show_module = true /> </#if> </#list> <#if show_module> <html> <head> <title>Extracted Attachments</title> </head> <body> <table border="1" cellspacing="0" margin="2"> <tr> <th>Attachments</th> </tr> <#assign extracted_attachments = rest("2.0", "/search?q=" + "SELECT * FROM attachments WHERE message.id = '1234'"?url) /> <#list extracted_attachments.data.items![] as att /> <tr> <td><ul><li><a href="${att.url}">${att.filename}</a> - ${att.content_type} - ${att.filesize}</li></ul></td> </tr> </#list> </table> </body> </html> </#if> </#if>
The error happens on the line starting with "<#assign extracted_attachments".
The 1234 is the id of a message which has attachments (In our Lithium instance that number is different).
Can someone please help and let me know what I've done wrong?
Thanks in advance!
Pro-tip when troubleshooting endpoint errors: Use the code as a component first.
In this case I ran it and voila:
ParseException:Syntax error in template "StringDisplay" in line 20, column 59: Encountered "/>", but was expecting: ">"