You are mixing too things, REST API access data. There is no support
for providing "official" REST reources from pages yet.
If you want to get the result of your script you need to access it
through
http://myhost/xwiki/get/MySpace/MyDocument?ouputSyntax=plain
On Fri, May 24, 2013 at 9:54 AM, <pierrick.bena(a)intech.lu> wrote:
Hi everybody,
I am new at XWiki and I would like to know if it's possible to build a JSON
object in a velocity script and get later this JSON via the REST API.
This is my script :
{{velocity}}
#if($xcontext.action == 'get' && "$!{request.outputSyntax}" ==
'plain')
$response.setContentType('application/json')
#end
#set($hql = "")
#set($results = $xwiki.searchDocuments($hql))
#set($json= "[" )
#set($started = false)
#foreach($item in $results)
#set($itemdoc = $xwiki.getDocument($item))
#if($started)
#set($pointvirgule=",")
#set($json = "${json} ${pointvirgule}" )
#else
#set($started = true)
#end
#set($suite="{ ""name"" :
""${itemdoc.fullName}""}")
#set($json= "${json} ${suite}")
#end
#set($fin="]")
#set($json= "${json} ${fin}")
$json
{{/velocity}}
I thought my JSON would be in the content of my page but when I try to get
this content with REST API I only have the velocity script in hard.
Someone could help me ?
Thanks in advance for your answers.
Pierrick
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
--
Thomas Mortagne