Sounds like a good start, well done Fabio.
Do we have a URI that exposes all available services yet?
Thanks
-Vincent
On Dec 31, 2008, at 12:09 AM, Fabio Mancinelli wrote:
Dear all,
I've committed a first implementation of the RESTful API as
described on
http://dev.xwiki.org/xwiki/bin/view/Design/RestfulAPI
Not all the URIs are working but pages and translations are.
You can:
* GET /
* GET /spaces
* GET /spaces/{spaceId}/pages
* GET|PUT /spaces/{spaceId}/pages/{pageId}
* GET|PUT /spaces/{spaceId}/pages/{pageId}/translations/
{translationId}
PUT will create/modify the corresponding page.
You can use curl to interoperate with the API. Some examples:
* curl -u Admin:admin -X PUT -d "Hello world" -H "Content-Type:
text/plain"
http://localhost:8080/xwiki/rest/spaces/Main/pages/WebHome
Will set the content of Main.WebHome to "Hello world"
* curl -u Admin:admin -X PUT -d @text.txt -H "Content-Type: text/
plain"
http://localhost:8080/xwiki/rest/spaces/Main/pages/WebHome
Will set the Main.WebHome content to whatever is writen in the
text.txt
file.
* curl -u Admin:admin -X PUT -d @page.xml -H "Content-Type:
application/xml"
http://localhost:8080/xwiki/rest/spaces/Main/pages/WebHome
Will set the Main.WebHome attributes to whatever is written in the
page.xml. The xml file must conform to the structure described in the
design page. This allows to change the content, the title and to
reparent the page.
* curl -u Admin:admin -X PUT -d @text.txt -H "Content-Type: text/
plain"
http://localhost:8080/xwiki/rest/spaces/Not/pages/Existing
Will create the Not.Existing page and set its content to whatever is
writen in the text.txt file.
Currently the implementation is in the sandbox and is available for
public review
(
http://svn.xwiki.org/svnroot/xwiki/sandbox/xwiki-core-rest/). It uses
the XStream library (
http://xstream.codehaus.org) for XML
serialization/deserialization of data types. Very handy.
Comments are welcome.
-Fabio