Reputation: 60213
I wrote an Alfresco Web Script that renders CSV, it works well.
In a particular case, I want the Web Script to return an error 500 as JSON, so I wrote a .json.500.ftl
template for it.
PROBLEM: The error 500 always shows up as HTML (the default Web Script error template).
What did I do wrong?
My files:
auditlog.get.desc.xml
auditlog.get.csv.ftl
auditlog.get.json.500.ftl
auditlog.get.json.500.ftl
just contains {"error": "abc is not correct"}
auditlog.get.desc.xml
contains:
<webscript>
<shortname>Audit Log Web Script</shortname>
<description>Returns audit data for a given day</description>
<url>/theapp/auditlog</url>
<authentication>admin</authentication>
<format default="csv"></format>
</webscript>
All of these files are in tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension/templates/webscripts/
and I have restarted Alfresco.
Upvotes: 0
Views: 330
Reputation: 3175
<format default="csv"></format>
Above line will try to fetch template with "auditlog.get.csv.500.ftl" name,which is not there in your case.
It will only try to fetch different response template if you are passing different parameter in url, something like below.
"http://localhost:8080/share/service/demo/webscript?format=json"
Upvotes: 2