Hello,
I am trying to create a space using Rest API with the following xml (with this URI : http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/SpaceTest/pages/WebHome/objects) :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<space>
<link href="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/SpaceTest/pages" rel="http://www.xwiki.org/rel/pages"/>
<link href="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/SpaceTest/pages/WebHome" rel="http://www.xwiki.org/rel/home"/>
<link href="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/SpaceTest/search" rel="http://www.xwiki.org/rel/search"/>
<id>xwiki:SpaceTest</id>
<wiki>xwiki</wiki>
<name>SpaceTest</name>
<home>xwiki:SpaceTest.WebHome</home>
<xwikiRelativeUrl>http://localhost:8080/xwiki/bin/view/SpaceTest/</xwikiRelativeUrl>
<xwikiAbsoluteUrl>http://localhost:8080/xwiki/bin/view/SpaceTest/</xwikiAbsoluteUrl>
</space>
But I get this result :
{"code":400,"contactEmail":null,"description":"The request could not be understood by the server due to malformed syntax","homeRef":"/","reasonPhrase":"Bad Request","uri":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1"}
What am I doing wrong ?
I am trying to create a space using Rest API
In practice spaces don’t really exist on their own, they are deduced from the existing documents references. This also means there is no entry point in the REST API to create spaces. So if you want to create a space the best is generally to create the space home page (the “WebHome”).
I have tried to create the WebHome Page by doing the following :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<page xmlns="http://www.xwiki.org">
<link href="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/SpaceTestA" rel="http://www.xwiki.org/rel/space" />
<link href="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/SpaceTestA/pages/WebHome/history" rel="http://www.xwiki.org/rel/history" />
<link href="http://localhost:8080/xwiki/rest/syntaxes" rel="http://www.xwiki.org/rel/syntaxes" />
<link href="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/SpaceTestA/pages/WebHome" rel="self" />
<link href="http://localhost:8080/xwiki/rest/wikis/xwiki/classes/SpaceTestA.WebHome" rel="http://www.xwiki.org/rel/class" />
<id>xwiki:SpaceTestA.WebHome</id>
<fullName>SpaceTestA.WebHome</fullName>
<wiki>xwiki</wiki>
<space>SpaceTestA</space>
<name>WebHome</name>
<title>WebHome</title>
<parent></parent>
<parentId></parentId>
<version>1.1</version>
<author>XWiki.Admin</author>
<xwikiRelativeUrl>http://localhost:8080/xwiki/bin/view/SpaceTestA/WebHome</xwikiRelativeUrl>
<xwikiAbsoluteUrl>http://localhost:8080/xwiki/bin/view/SpaceTestA/WebHome</xwikiAbsoluteUrl>
<translations/>
<syntax>xwiki/2.1</syntax>
<language></language>
<majorVersion>1</majorVersion>
<minorVersion>1</minorVersion>
<hidden>false</hidden>
<created></created>
<creator>XWiki.Admin</creator>
<modified></modified>
<modifier>XWiki.Admin</modifier>
<comment></comment>
<content></content>
</page>
It won’t work and it returns this error message : “Could not convert the message body to a org.xwiki.rest.model.jaxb.Page”
If I try to create the page on an existing space, it does create the page.
EDIT : Solved by specifying a date in modified and created tags.