When I tried to apply rest api to get children like following.
https://test.com/rest/wikis/xwiki/spaces/XXX/spaces/test/pages/WebHome/children
I could only get the page tag result like following.
<pages/>
Where is child list ? and how can I get them ?
When I tried
https://test.com/rest/wikis/xwiki/spaces/XXX/spaces/test/pages/WebHome/
I can get following
<page>
<id> </id>
<fullName></fullName>
<wiki></wiki>
<space></space>
<name></name>
<title></title>
<parent/>
<parentId/>
<version>12.1</version>
<author>XWiki.test</author>
<xwikiRelativeUrl>https://test.com/bin/view/XXX/test/</xwikiRelativeUrl>
<xwikiAbsoluteUrl>https://test.com/bin/view/XXX/test/</xwikiAbsoluteUrl>
<translations/>
<syntax>xwiki/2.1</syntax>
<language/>
<majorVersion>12</majorVersion>
<minorVersion>1</minorVersion>
<hidden>false</hidden>
<created>2021-01-06T03:47:45Z</created>
<creator>XWiki.test</creator>
<modified>2021-02-12T00:25:55Z</modified>
<modifier>XWiki.test</modifier>
<comment/>
<content>test</content>
</page>
Are there good way to get the list of children ?
I wanna know how to get child list very much.
If someone has opinion, please let me know. Thanks
I’m looking for the same answer.
Receive a list of child pages of one space/one sub-page, recursively.
More precisely, I want to have a list of pages, which were recently changed/added and I want to limit this result to 5.
I guess, the only way to implement this is by creating a velocity macro?
This works liike a charm:
curl -u api_user -H "Accept: application/json" 'http:/192.168.0.13:8080/rest/wikis/xwiki/query?q=where%20doc.space%20like%20%27Linux%20Wiki%25%27&type=xwql&order=desc&number=5' | jq
This works somehow. Unfortunately, it does not return the 5 last-modified wiki pages.
Then I tried:
curl -u api_user -H "Accept: application/json" 'http:/192.168.0.13:8080/rest/wikis/xwiki/query?q=where%20doc.space%20like%20%27Linux%20Wiki%25%27%20order%20by%20doc.date%20desc&type=xwql&order=desc&number=20'
but this returns always:
org.xwiki.query.QueryException: Exception while executing query. Query statement = [ select distinct doc.fullName , doc.space , doc.name , doc.language from XWikiDocument as doc where doc.space like 'Linux Wiki%' order by doc.date desc ]
PSQLException: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
Looks like, the date (or creationDate) isn’t part of the “common” xwql select list. I guess, this is a reason that xwql can not be used to get the last-modified entries. Am I right?
Then I tries with HQL:
curl -u api_user -H "Accept: application/json" 'http:/192.168.0.13:8080/rest/wikis/xwiki/query?q=select%20doc.space%20from%20XWikiDocument%20as%20doc%20where%20doc.space%20like%20%27Linux%20Wiki%25%27%20order%20by%20doc.name&type=hql'
Which always returned:
{"links":[],"searchResults":[],"template":"http://192.168.0.13:8080/rest/wikis/xwiki/query?q={query}(&type={type})(&number={number})(&start={start})(&orderField={fieldname}(&order={asc|desc}))(&distinct=1)(&prettyNames={false|true})(&wikis={wikis})(&className={classname})"}
Actually, I wasn’t able to get any result by using HQL syntax. Maybe someone can help?
vmassol
February 22, 2022, 5:17pm
4
sbernhard:
but this returns always:
org.xwiki.query.QueryException: Exception while executing query. Query statement = [ select distinct doc.fullName , doc.space , doc.name , doc.language from XWikiDocument as doc where doc.space like 'Linux Wiki%' order by doc.date desc ]
PSQLException: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
Looks like, the date (or creationDate) isn’t part of the “common” xwql select list. I guess, this is a reason that xwql can not be used to get the last-modified entries. Am I right?
Yes. You could try using a full XWQL query (i.e. that starts with SELECT
). See examples at https://extensions.xwiki.org/xwiki/bin/view/Extension/Query%20Module
However note this limitation: https://extensions.xwiki.org/xwiki/bin/view/Extension/Query%20Module#HAllowedHQL2FXWQLselectqueries
Well, this would mean, its not possible to “order” the returned pages based on a date => 5 last modified pages.
I think, this can not be and I do something wrong.
I tried some more ways to get the latest X pages based on the 'modified date ’ but was not able to do it. Does someone have another suggestion?