Quantcast

Rest API to create pages (and pages within pages)

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

Rest API to create pages (and pages within pages)

jhuerta
Hi,

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.

"http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/2017-2020/pages/madrid
"
"
http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/2017-2020/spaces/madrid/pages/cibeles
"


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,

 Juan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rest API to create pages (and pages within pages)

Marius Dumitru Florea
Hi Juan,

You got it almost right, but you need to read
http://platform.xwiki.org/xwiki/bin/view/Features/ContentOrganization/ ,
especially the part that explains the difference between terminal and
non-terminal pages.

On Wed, Mar 1, 2017 at 11:13 PM, Juan Huerta <[hidden email]> wrote:

> Hi,
>
> 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.
>
>

> "http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/2017-
> 2020/pages/madrid
>

This creates a terminal page "madrid".


> "
> "
>
> <http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/2017-2020/spaces/madrid/pages/cibeles>



> http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/2017-
> 2020/spaces/madrid/pages/cibeles
>

This creates a terminal page "cibeles" inside a non-terminal page "madrid".


> "
>
>
> 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"
>

Exactly. One is terminal and the other one is non-terminal. The actual
references (identifiers) are:

xwiki:2017-2020.madrid <--- this is the terminal page (can't have child
pages)
xwiki:2017-2020.madrid.WebHome <--- this is the non-terminal page (can have
child page)

Hope this helps,
Marius


>
>  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,
>
>  Juan
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rest API to create pages (and pages within pages)

jhuerta
Hi Marius,

Thanks a lot for your help.

Actually, after browsing the forum, I found someone had a similar problem
(or so I thought). And I thought that my solution was along the lines of
setting the parent and parentId of the pages (while calling the API and as
data passed in the call) .

http://xwiki.475771.n2.nabble.com/when-creating-a-page-via-REST-it-doesn-t-
appear-in-children-via-REST-td7601706.html

Thanks again for your help and I'll check on it.

Cheers,

Juan

2017-03-02 9:34 GMT+01:00 Marius Dumitru Florea <
[hidden email]>:

> Hi Juan,
>
> You got it almost right, but you need to read
> http://platform.xwiki.org/xwiki/bin/view/Features/ContentOrganization/ ,
> especially the part that explains the difference between terminal and
> non-terminal pages.
>
> On Wed, Mar 1, 2017 at 11:13 PM, Juan Huerta <[hidden email]>
> wrote:
>
> > Hi,
> >
> > 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.
> >
> >
>
> > "http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/2017-
> > 2020/pages/madrid
> >
>
> This creates a terminal page "madrid".
>
>
> > "
> > "
> >
> > <http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/2017-
> 2020/spaces/madrid/pages/cibeles>
>
>
>
> > http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/2017-
> > 2020/spaces/madrid/pages/cibeles
> >
>
> This creates a terminal page "cibeles" inside a non-terminal page "madrid".
>
>
> > "
> >
> >
> > 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"
> >
>
> Exactly. One is terminal and the other one is non-terminal. The actual
> references (identifiers) are:
>
> xwiki:2017-2020.madrid <--- this is the terminal page (can't have child
> pages)
> xwiki:2017-2020.madrid.WebHome <--- this is the non-terminal page (can have
> child page)
>
> Hope this helps,
> Marius
>
>
> >
> >  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,
> >
> >  Juan
> >
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rest API to create pages (and pages within pages)

Marius Dumitru Florea
On Thu, Mar 2, 2017 at 10:38 AM, Juan Huerta <[hidden email]> wrote:

> Hi Marius,
>
> Thanks a lot for your help.
>
> Actually, after browsing the forum, I found someone had a similar problem
> (or so I thought). And I thought that my solution was along the lines of
> setting the parent and parentId of the pages (while calling the API and as
> data passed in the call) .
>

The parent field has been deprecated
http://platform.xwiki.org/xwiki/bin/view/Features/ContentOrganization/NestedPagesMigration/#HParent2FChildrelationship
.


>
> http://xwiki.475771.n2.nabble.com/when-creating-a-page-via-
> REST-it-doesn-t-
> appear-in-children-via-REST-td7601706.html
> <http://xwiki.475771.n2.nabble.com/when-creating-a-page-via-REST-it-doesn-t-%0Aappear-in-children-via-REST-td7601706.html>
>
> Thanks again for your help and I'll check on it.
>
> Cheers,
>
> Juan
>
> 2017-03-02 9:34 GMT+01:00 Marius Dumitru Florea <
> [hidden email]>:
>
> > Hi Juan,
> >
> > You got it almost right, but you need to read
> > http://platform.xwiki.org/xwiki/bin/view/Features/ContentOrganization/ ,
> > especially the part that explains the difference between terminal and
> > non-terminal pages.
> >
> > On Wed, Mar 1, 2017 at 11:13 PM, Juan Huerta <[hidden email]>
> > wrote:
> >
> > > Hi,
> > >
> > > 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.
> > >
> > >
> >
> > > "http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/2017-
> > > 2020/pages/madrid
> > >
> >
> > This creates a terminal page "madrid".
> >
> >
> > > "
> > > "
> > >
> > > <http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/2017-
> > 2020/spaces/madrid/pages/cibeles>
> >
> >
> >
> > > http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/2017-
> > > 2020/spaces/madrid/pages/cibeles
> > >
> >
> > This creates a terminal page "cibeles" inside a non-terminal page
> "madrid".
> >
> >
> > > "
> > >
> > >
> > > 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"
> > >
> >
> > Exactly. One is terminal and the other one is non-terminal. The actual
> > references (identifiers) are:
> >
> > xwiki:2017-2020.madrid <--- this is the terminal page (can't have child
> > pages)
> > xwiki:2017-2020.madrid.WebHome <--- this is the non-terminal page (can
> have
> > child page)
> >
> > Hope this helps,
> > Marius
> >
> >
> > >
> > >  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,
> > >
> > >  Juan
> > >
> >
>
Loading...