REST API ... calls not working

I have only been using XWiki for a short time. I am running an XWiki instance, version 16.10.2, as a Docker container. The instance is running and doing what it is supposed to do. Since I want to create many pages, I would like to use the REST API … but nothing is working.

My REST API calls, for example, retrieving the list of all subwikis, are syntactically correct (tested in the XWiki Cloud: https://XXXX.demo.xwiki.com), but in my local instance, the request only returns garbage.

Here’s the call
curl -u user:pw -X GET http://localhost:8021/xwiki/rest/wikis?media=json … returns only a mess of html code

I have two questions:

  • could a configuration error cause this behavior? i appended ‘xwiki.rest=1’ in xwiki.cfg

  • are there other tutorials, howtos, videos (videos on youtube are not helpul)? I checked reddit, but there is nothing valuable.

Every tip is welcome.

Thanks in advance.

I think your problem might be that in the Docker container, XWiki is installed as the root web application, so you don’t need the xwiki prefix in the URL. So the URL should be http://localhost:8021/rest/wikis?media=json.

Hi Michael,
great, many thanks.

curl -u user:pw -X GET http://localhost:9021/rest/wikis?media=json |jq |grep id

  "id": "subwiki1",
  "id": "subwiki2",
  "id": "xwiki",
  ...

I had oncemore a look at the REST API Documentation (https://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/XWikiRESTfulAPI)
where accessing the service is given by http://host:port/xwiki/rest.
Perhaps i didn´t understand everything but there is no note on the different url in case of XWiki is installed as the root web application.

Do you have an other source of information to the usage of REST API?

I’ve updated the documentation at https://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/XWikiRESTfulAPI to document this case.

Being a developer of XWiki, I usually just directly locate the respective resource definition in my IDE. As far as I know, this page that you already found is the main documentation of XWiki’s REST API, I’m not aware of other pages for the core API. Extensions that contribute REST endpoints might have separate documentation pages for them.