I have a main function in my webscript:
mywebscript.js
function main()
{
....
....
return arr;
}
main();
How do I get arr when I call this script using curl command.
curl "http://.../alfresco/service/mywebscript"
Solved! Go to Solution.
Hi:
Your freemaker template may render in json format, and then you can parse your curl result via jq or jshon commands instead of greping this way.
Regards.
--C.
You must write a response template using FreeMarker template to render the HTTP response. You will not automatically get "arr" as a response. Also, for the template to be able to render elements of "arr" you must put it into the "model" variable, e.g. "model.arr = arr;"
Yeah I can write "model.arr = arr" in my script and fetch its value in FreeMarker template using ${arr}. but arr is an associative array and I need to loop through that and feed the values into an sql table which is where I am calling the curl command in a ruby based script.
I can fetch the value of a <p></p> tag of FreeMarker template file using :
curl "http://.../alfresco/service/mywebscript" | grep \'(?<=<p>).*?(?=</p>)\' but I cannot grep on a table and get the value of multiple <td></td>s.
And that is why I need arr to fetch where I am calling curl.
Hi:
Your freemaker template may render in json format, and then you can parse your curl result via jq or jshon commands instead of greping this way.
Regards.
--C.
Rendering in json ftl worked .
Thank you.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.