Rest API to create pages (and pages within pages)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Rest API to create pages (and pages within pages)

This post has NOT been accepted by the mailing list yet.

I'm quite new in XWiki and trying to use the RestAPI to create pages, and pages inside pages (which I think is called spaces).  I have the feeling that 'spaces' is a legacy term, and that in the current XWiki (Enterprise 9.1), an space is just a page that contains other pages. Kindly correct me if I'm wrong, but I have not find anywhere how to create an space.

Below the 2 URLs I'm using to create the pages. In both cases, when I use PUT to call the 2 urls, I pass as data a content and a title. I have no problem with the title and the content, both are being created correctly. My end goal is to create pages, and pages withing pages.


In both cases, I'm using PUT and I'm able to create pages successfully, however, not as I want:

- "http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/2017-2020/pages/madrid"
This one creates a page called "madrid" (with the content I pass)

- "http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/2017-2020/spaces/madrid/pages/cibeles"
I would expect this one to create a page named "cibeles" inside the previous "madrid" page.
Instead, it creates a new "madrid" page (without any text in the content, which is fine as I dont pass anything), and inside this page, the "cibeles" page (with the content I expect)

So, I end up having TWO pages named "madrid"

 One points to "http://localhost:8080/xwiki/bin/view/2017-2020/madrid/" (and have inside a page named cibeles) . This "madrid" page displays this text: "The requested page could not be found.", although inthe hierarchy tree I see it has a page inside.

 The other (without a nested page), points to: "http://localhost:8080/xwiki/bin/view/2017-2020/madrid" and has a proper content (which I passed in the PUT request)

 (notice the / at the end of the URL, "madrid" vs "madrid/" )

 How to indicate that the page should be created in an existing page without the need to create this new parent page? Or even if I have to create first the parent page, how to tell that the child page should be inside that existing parent page?

 Thanks for your help,