Performing an xwql query with “select …” using velocity and $services.xwql.query(“…”).execute() works. But I cannot get the same query to work using the REST call https://<hostname>/xwiki/rest/wikis/xwiki/query?q=select ....
Is this possible? Or does this only work when using a page?
I have tried some simple queries without the “select” part using REST and they work.
BTW, I have looked at a lot of posts and grok, but no success.
In Velocity, $services.xwql.query("…").execute() lets you write full XWQL statements, including select …, because it directly uses the Query API.
The REST /query endpoint works differently: it automatically prebuilds the select and from parts for you. The q= parameter is meant to contain only the conditions, joins, and ordering fragments. That’s why queries with select … fail over REST but succeed in Velocity.
So yes, this is expected. With REST you should omit the select clause and just provide the rest of the query. The endpoint will always wrap it into something like: select doc.fullName from XWikiDocument doc <your fragment>
This design keeps the REST output consistent and safe.