Skip navigation
All Places > Connect > Blog > Author: sakshik


1 Post authored by: sakshik

JSON FreeMarker Alfresco

Posted by sakshik Aug 4, 2017

Steps to get JSON data from calling a webscript through curl command.


Suppose your javascript has an array of node objects of Alfresco and you want to print their names and paths in json format:


Step 1: Create a file testjson.get.xml in ..Data Dictionary/Web Scripts

<?xml version="1.0" encoding="UTF-8"?>


Step 2: Create a file testjson.get.js which has the array you want to get in json format


docnodes = [node1,node2,node3]; // array of nodes of alfresco

model.docnodes = docnodes; // to be able to use this array in json ftl file


Step 3: Create a file testjson.get.json.ftl


<#list docnodes as d>
"name" : "${}",
"path" : "${d.displayPath}"
}<#if d_has_next>,</#if>


Step 4: 

Go to https://<hostname>/alfresco/service/

Click Refresh Web Scripts to register your new webscript


Calling through curl command:


curl -s -u "<username>":"<password>"  "https://<hostname>/alfresco/service/testjson.json"