Wiki source code of The XWiki RESTful API

Version 42.1 by Thomas Mortagne on 2014/11/21

Hide last authors
Jerome 20.1 1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc depth="2"/}}
3 {{/box}}
Fabio Mancinelli 1.1 4
Silvia Macovei 10.5 5 XWiki provides fine-grain access to virtually every element through an API that is based on HTTP semantics, i.e., a RESTful API. In this page you will find all the details to take advantage of this API and the instructions to use it at its full potential.
Fabio Mancinelli 1.1 6
Jerome 20.1 7 = Accessing the service =
Fabio Mancinelli 16.1 8
Fabio Mancinelli 17.1 9 By defaut the XWiki RESTful API entrypoint is rooted at the following URI:
10
11 {{code}}
12
13 http://host:port/xwiki/rest
14
15 {{/code}}
16
Vincent Massol 17.2 17 All the resource references described in the [[XWiki RESTful API Documentation>>#HXWikiRESTfulAPIDocumentation]] should be intended relative to this URL.
Fabio Mancinelli 17.1 18
Manuel Smeria 40.7 19 For example the ##/wikis## resources on a server running on ##localhost## on port ##8080## can be retrieved using the following URL : ##http:~/~/localhost:8080/xwiki/rest/wikis##
Fabio Mancinelli 17.1 20
Manuel Smeria 40.7 21 In addition to retrieving content in XML format, you can also retrieve it in JSON format by adding the parameter ##?media=json## in the URL. For example: ##http:~/~/localhost:8080/xwiki/rest/wikis?media=json##
Ludovic Dubost 25.1 22
Vincent Massol 14.2 23 = Dataset =
Fabio Mancinelli 1.1 24
25 This section contains a brief and high-level description of the XWiki data set that should serve as a basis for presenting resources and their associated operations.
26
Silvia Macovei 10.3 27 XWiki has **pages** organized in **spaces**. Each **page** is available in multiple **versions** (its **history**) and **translations**. Translated pages have their own **versions** and **history** which are independent. Each page might have **attachments**. Each attachment has its own **history**. Attachments are shared among all the different translations of a page (i.e., the same set of attachments is the same regardless of the page language). Pages can have one or more **objects**. Objects are instances of a **class** that contains a set of **properties**. Some objects might be directly exposed as first class entities, such as **comments** and **tags**. Objects, as attachments, are shared among all page translations.
Fabio Mancinelli 1.1 28
Vincent Massol 14.2 29 = Understanding resources and representations =
Fabio Mancinelli 1.1 30
Manuel Smeria 40.6 31 "An important concept in REST is the existence of resources (sources of specific information), each of which is referenced with a global identifier (e.g., an URI in HTTP). In order to manipulate these resources, components of the network (user agents and origin servers) communicate via a standardized interface (e.g., HTTP) and exchange representations of these resources (the actual documents conveying the information)." ([[Wikipedia>>http://en.wikipedia.org/wiki/Representational_State_Transfer#Central_principle]])
Fabio Mancinelli 1.1 32
Manuel Smeria 40.8 33 Resources in XWiki are pages, attachments, objects, properties, spaces, and all the //things// we described in the previous section. XWiki has a default way of conveying the information about these resources, i.e., by providing well defined XML representations that contain all the information associated to the resource in an XML format. This format is described using an [[XML Schema Definition file>>https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-model/src/main/resources/xwiki.rest.model.xsd]].
Fabio Mancinelli 1.1 34
Silvia Macovei 10.4 35 Of course the same resource can be represented in many different ways. This is yet to be documented.
Fabio Mancinelli 1.1 36
Silvia Macovei 10.4 37 Another important aspect of representations is that they contain useful information for linking related resources. This is a realization of the //Hypermedia As The Engine Of The Application State (HATEOAS)// principle. In XML representations this information is conveyed through the ##<link>## tag. This tag has two important parameters: **rel** and **href**. **rel** specifies the "semantics" of the link, while **href** is the URI of the linked resource.
Silvia Macovei 9.2 38
Fabio Mancinelli 1.1 39 For example, in the representation of a page, we can have links to the comments, tags, attachments which are independent resources associated to the current page. These links are provided in the XML representation of a page and allow a client to navigate to related resources... Like we do every day when we click on a link in a web page.
Silvia Macovei 9.2 40
Silvia Macovei 9.1 41 [[image:representation||height="430"]]
Fabio Mancinelli 1.1 42
Vincent Massol 14.2 43 == Relations ==
Fabio Mancinelli 1.1 44
Fabio Mancinelli 5.1 45 The available relations that you might find in the XML resource representations are the following:
Fabio Mancinelli 1.1 46
Silvia Macovei 9.1 47 |=Rel|=Semantics
Fabio Mancinelli 15.1 48 |{{{http://www.xwiki.org/rel/wikis}}}|The representation containing the list of virtual wikis.
49 |{{{http://www.xwiki.org/rel/spaces}}}|The representation containing the list of spaces in a wiki.
50 |{{{http://www.xwiki.org/rel/pages}}}|The representation containing the list of pages in a space.
51 |{{{http://www.xwiki.org/rel/translation}}}|The representation containing a translation of a page.
52 |{{{http://www.xwiki.org/rel/page}}}|The representation for a page.
53 |{{{http://www.xwiki.org/rel/space}}}|The representation for a space.
54 |{{{http://www.xwiki.org/rel/parent}}}|The representation for the page that is parent of the current resource.
55 |{{{http://www.xwiki.org/rel/home}}}|The representation for the page that is the home of the current resource.
56 |{{{http://www.xwiki.org/rel/attachmentData}}}|The representation of the actual attachment data.
57 |{{{http://www.xwiki.org/rel/comments}}}|The representation of the list of comments associated to the current resource.
58 |{{{http://www.xwiki.org/rel/attachments}}}|The representation of the list of attachments associated to the current resource.
59 |{{{http://www.xwiki.org/rel/objects}}}|The representation of the list of objects associated to the current resource.
60 |{{{http://www.xwiki.org/rel/object}}}|The representation for an object.
61 |{{{http://www.xwiki.org/rel/classes}}}|The representation of the list of classes associated to the current resource.
62 |{{{http://www.xwiki.org/rel/history}}}|The representation of the list of history information associated to the current resource.
63 |{{{http://www.xwiki.org/rel/class}}}|The representation for a class.
64 |{{{http://www.xwiki.org/rel/property}}}|The representation for a property.
65 |{{{http://www.xwiki.org/rel/properties}}}|The representation of the list of properties associated to the current resource.
66 |{{{http://www.xwiki.org/rel/modifications}}}|The representation of the list of modifications associated to the current resource.
67 |{{{http://www.xwiki.org/rel/children}}}|The representation of the list of children associated to the current resource.
68 |{{{http://www.xwiki.org/rel/tags}}}|The representation of the list of tags associated to the current resource.
69 |{{{http://www.xwiki.org/rel/tag}}}|The representation of a tag.
70 |{{{http://www.xwiki.org/rel/search}}}|The representation for a search resource.
Fabio Mancinelli 32.1 71 |{{{http://www.xwiki.org/rel/syntaxes}}}|The representation for a syntax resource.
Silvia Macovei 9.2 72
Silvia Macovei 8.3 73 Relations are defined as URIs in order to provide a sort of namespace. Currently these URIs are not links to real web pages but, in the future, they might point to descriptions of their semantics on actual web pages (or other kinds of representations).
Fabio Mancinelli 1.1 74
Vincent Massol 14.2 75 == The "HATEOAS" Graph ==
Fabio Mancinelli 1.1 76
Manuel Smeria 40.6 77 In order to better understand the relations among resources you might have a look at this [[graph>>attach:XWikiHATEOAS.pdf]] that pictures all the resources available in the XWiki RESTful API and the relations among them. In this graph, nodes are [[URI templates>>http://code.google.com/p/uri-templates/]] representing classes of resources. Edges are the possible links that you might find in a representation of a given resource, and their associated relations.
Silvia Macovei 9.2 78
Fabio Mancinelli 1.1 79 This graph shows that by starting from the API entry-point a client can navigate and discover all the resources just by following the links provided in representations (and by knowing their semantics). This was exactly the way how this graph was generated.
80
Vincent Massol 14.2 81 = Interacting with the XWiki RESTful API =
Silvia Macovei 8.2 82
Oana Florea 9.5 83 The XWiki RESTful API is accessible through HTTP so, in principle, you can use every client that is capable of "speaking" HTTP in order to interact with it. Even a web browser!
Silvia Macovei 9.1 84 If you want to write more complex programs you might download an HTTP library for your favorite language (e.g., [[http://hc.apache.org/]]).
Silvia Macovei 9.2 85
Vincent Massol 40.2 86 Java users might take advantage of the [[JAXB>>http://jaxb.java.net/]] framework and its [[XJC binding compiler>>http://jaxb.java.net/2.2.4/docs/xjc.html]] in order to generate domain object models directly from the [[XML Schema Definition>>https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-model/src/main/resources/xwiki.rest.model.xsd]], and use them for serializing and de-serializing XML representations.
Silvia Macovei 9.2 87
Fabio Mancinelli 5.1 88 If you use this approach (Apache HTTP Client + JAXB) you will find yourself writing some code like this:
Fabio Mancinelli 1.1 89
Fabio Mancinelli 19.1 90 {{code language="java"}}
91 import javax.xml.bind.JAXBContext;
92 import javax.xml.bind.Unmarshaller;
93
94 import org.apache.commons.httpclient.HttpClient;
95 import org.apache.commons.httpclient.methods.GetMethod;
96 import org.xwiki.rest.model.jaxb.Page;
97
98 ...
Fabio Mancinelli 1.1 99 HttpClient httpClient = new HttpClient();
Ludovic Dubost 18.1 100 JAXBContext context = JAXBContext.newInstance("org.xwiki.rest.model.jaxb");
Fabio Mancinelli 19.1 101 Unmarshaller unmarshaller = context.createUnmarshaller();
Fabio Mancinelli 1.1 102
103 GetMethod getMethod = new GetMethod("http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome");
104 getMethod.addRequestHeader("Accept", "application/xml");
105 httpClient.executeMethod(getMethod);
106
107 Page page = (Page) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
Silvia Macovei 9.1 108 {{/code}}
Fabio Mancinelli 1.1 109
Fabio Mancinelli 5.1 110 And you will have all the information about the Main.WebHome page in the Page object, without the need of handling XML directly.
Silvia Macovei 9.2 111
Silvia Macovei 9.1 112 Because of the wide variety of HTTP frameworks available we don't provide a full tutorial about using them. However, in order to show you how to interact with the XWiki RESTful API, we will use [[curl>>http://curl.haxx.se]]: a standard command line HTTP client that provides an interface to all the functionalities of the HTTP protocol.
Silvia Macovei 9.2 113
Fabio Mancinelli 5.1 114 By using curl, the previous example would have been:
Fabio Mancinelli 1.1 115
Fabio Mancinelli 19.1 116 {{code language="xml"}}
Fabio Mancinelli 1.1 117 $ curl http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome
118 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
119 <page xmlns="http://www.xwiki.org">
120 <link rel="http://www.xwiki.org/rel/space" href="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main"/>
121 ...
Silvia Macovei 9.1 122 {{/code}}
Fabio Mancinelli 1.1 123
Vincent Massol 14.2 124 == Authentication ==
Fabio Mancinelli 1.1 125
Fabio Mancinelli 5.1 126 The XWiki RESTful API supports two types of authentication:
Fabio Mancinelli 1.1 127
Silvia Macovei 9.1 128 * **HTTP BASIC Auth**: You provide your credentials using the Authorization HTTP header
129 * **XWiki session**: If you are logged in XWiki and you use the cookies provided by the authentication mechanism, you will also be authenticated to the XWiki RESTful API. This is useful, for example, when you are interacting with the API using the XMLHttpRequest object of a browser using Javascript.
Silvia Macovei 9.2 130
Fabio Mancinelli 5.1 131 If you don't provide any credentials the XWiki RESTful API will recognize you as a XWiki.Guest user.
Silvia Macovei 9.2 132
Fabio Mancinelli 5.1 133 So if you have, let's say a Main.PrivatePage, and you try to do:
Fabio Mancinelli 1.1 134
Silvia Macovei 10.6 135 {{code language="none"}}
Fabio Mancinelli 1.1 136 $ curl -v http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/PrivatePage
137 ...
138 < HTTP/1.1 401 Unauthorized
139 ...
Silvia Macovei 9.1 140 {{/code}}
Fabio Mancinelli 1.1 141
Silvia Macovei 9.3 142 You will get an Unauthorized empty response.
Silvia Macovei 9.2 143
Fabio Mancinelli 1.1 144 On the contrary, by specifying Admin credentials you gain access to the actual page:
145
Fabio Mancinelli 19.1 146 {{code language="xml"}}
Fabio Mancinelli 1.1 147 $ curl -u Admin:admin http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/PrivatePage
148 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
149 <page xmlns="http://www.xwiki.org">
150 <link rel="http://www.xwiki.org/rel/space" href="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main"/>
151 ...
152 <content>Only admin can see this</content>
153 </page>
Silvia Macovei 9.1 154 {{/code}}
Fabio Mancinelli 1.1 155
Vincent Massol 14.2 156 == Sending representations ==
Fabio Mancinelli 1.1 157
158 Many resources are modifiable, so you can send representations in order to change the state of those resources (e.g., pages).
Vincent Massol 28.4 159 All modifiable resources accept XML representations that conform to the [[XML Schema Definition>>https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-model/src/main/resources/xwiki.rest.model.xsd]]. However, some other representations might be accepted as well (see the following sections).
Silvia Macovei 9.2 160
Fabio Mancinelli 1.1 161 Resource update is usually done by using the PUT method, while resource creation is done via PUT or POST.
Silvia Macovei 9.2 162
Fabio Mancinelli 1.1 163 For example, in order to create a page you might do the following:
164
Fabio Mancinelli 19.1 165 {{code language="xml"}}
Sergiu Dumitriu 20.2 166 $ curl -u Admin:admin -X PUT --data-binary "@newpage.xml" -H "Content-Type: application/xml" http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/NewPage
Fabio Mancinelli 1.1 167 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
168 <page xmlns="http://www.xwiki.org">
169 <link rel="http://www.xwiki.org/rel/space" href="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main"/>
170 ...
171 <version>1.1</version>
172 <majorVersion>1</majorVersion>
173 <minorVersion>1</minorVersion>
174 <created>2009-03-21+01:00</created>
175 <creator>XWiki.Admin</creator>
176 <modified>2009-03-21+01:00</modified>
177 <modifier>XWiki.Admin</modifier>
178 <content>This is a new page</content>
179 </page>
Silvia Macovei 9.1 180 {{/code}}
Fabio Mancinelli 1.1 181
182 Where newpage.xml is an XML file containing
183
Fabio Mancinelli 19.1 184 {{code language="xml"}}
Fabio Mancinelli 1.1 185 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
186 <page xmlns="http://www.xwiki.org">
187 <title>Hello world</title>
Fabio Mancinelli 32.1 188 <syntax>xwiki/2.0</syntax>
Fabio Mancinelli 1.1 189 <content>This is a new page</content>
190 </page>
Silvia Macovei 9.1 191 {{/code}}
Fabio Mancinelli 1.1 192
193 The page has been created and is accessible. Subsequent PUT requests to the page URI will modify its content.
194
Fabio Mancinelli 32.1 195 You can specify a subset of the three elements {{{title}}}, {{{syntax}}}, and {{{content}}} in the XML when updating/creating a page.
196 For example, if you just want to change the title, it is sufficient to specify only the {{{title}}} element. The current content and the syntax of the page will be left unchanged.
197
Vincent Massol 14.2 198 == Overcoming browser limitations ==
Fabio Mancinelli 1.1 199
Silvia Macovei 10.4 200 As said before, it could be useful to send information by using browser's XmlHttpRequest objects. However, currently many browsers only support GET and POST methods, so it is impossible to send, for example, PUT requests. In order to overcome this limitation you can override the HTTP Method by specifying a ##method## parameter in the URI query string.
Silvia Macovei 9.2 201
Manuel Smeria 40.7 202 In the previous example, if you send a POST request to the ##http:~/~/localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/NewPage?method=PUT## it will be interpreted as if it were an actual PUT request.
Fabio Mancinelli 1.1 203
204 This overriding mechanism allows the interaction with the XWiki RESTful API by using any kind of browser.
205
Vincent Massol 14.2 206 == PUT vs POST ==
Fabio Mancinelli 1.1 207
Silvia Macovei 10.4 208 In the following sections you will see that sometimes resources are created by using PUT and sometimes by using POST. The general principle is that if the client is responsible for choosing the resource URI then PUT is used. If it's the server that bears this responsibility, then POST is used.
Fabio Mancinelli 1.1 209
Silvia Macovei 10.4 210 To be clearer, when a client wants to create a page it knows **where** that page should go, so it is able to communicate the server the target URI. PUT is used.
Fabio Mancinelli 1.1 211
Oana Florea 9.5 212 A client, on the contrary, cannot know beforehand what will be the URI of a comment, since comment URIs contains the ID of the comment and this information is generated by the server. In this case the client will do a POST and the server, in response, will communicate the URI it generated for the newly created comment.
Fabio Mancinelli 1.1 213
Vincent Massol 14.2 214 = XWiki RESTful API Documentation =
Silvia Macovei 8.4 215
Oana Florea 9.5 216 In this section you will find the documentation of the whole XWiki RESTful API.
Fabio Mancinelli 1.1 217
Manuel Smeria 40.8 218 **application/xml** representations refers to the [[XML Schema Definition>>https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-model/src/main/resources/xwiki.rest.model.xsd]].
Fabio Mancinelli 1.1 219
Manuel Smeria 40.6 220 Resource URIs are specified using [[URI templates>>http://code.google.com/p/uri-templates/]]. Bracketed elements are formal parameters and should be instantiated to actual values in order to retrieve the associated resource.
Fabio Mancinelli 1.1 221
Vincent Massol 14.2 222 == Root resources ==
Fabio Mancinelli 1.1 223
Jerome 20.1 224 By defaut all the resources of the RESTful API are rooted at the following URI: ##http:~/~/server:port/xwiki/rest/## (depending on where your XWiki is running)
Fabio Mancinelli 16.1 225
Vincent Massol 14.2 226 === / ===
Silvia Macovei 9.1 227
228 * **HTTP Method:** GET
229 ** **Media types:**
Fabio Mancinelli 1.1 230 *** application/xml (XWiki element)
Vincent Massol 33.1 231 ** **Description:** Retrieves the entry root description containing information about the server (currently returns the XWiki product Version).
Silvia Macovei 9.1 232 ** **Status codes:**
Fabio Mancinelli 1.1 233 *** 200: If the request was successful.
234
Manuel Smeria 40.7 235 === /syntaxes ===
Fabio Mancinelli 32.1 236
237 * **HTTP Method:** GET
238 ** **Media types:**
239 *** application/xml (Syntaxes element)
240 ** **Description:** The list of syntaxes supported by the XWiki instance.
241 ** **Status codes:**
242 *** 200: If the request was successful.
243
Vincent Massol 14.2 244 === /wikis ===
Silvia Macovei 9.1 245
246 * **HTTP Method:** GET
247 ** **Media types:**
Fabio Mancinelli 1.1 248 *** application/xml (Wikis element)
Fabio Mancinelli 32.1 249 ** **Description:** The list of wikis available on the XWiki instance. Unless the wiki is configured to be a wiki farm, this list is usually made of a single element 'xwiki'.
Silvia Macovei 9.1 250 ** **Status codes:**
Fabio Mancinelli 1.1 251 *** 200: If the request was successful.
252
Manuel Smeria 40.7 253 === /wikis/query?q~={query}&wikis~=wikiList[&distinct~={true,false}][&order~={asc,desc}][&start~=n][&number~=n][&prettyNames~={true,false}][&className~=className] ===
Silvia Macovei 9.1 254
255 * **HTTP Method:** GET
256 ** **Media types:**
Fabio Mancinelli 1.1 257 *** application/xml (SearchResults element)
Thomas Mortagne 42.1 258 ** **Description:** Search resources (pages and attachments):
259 *** [since 6.4] using a SOLR query (handled by the [[SOLR Query module>>extensions:Extension.Solr Search Query API]]) on the wikis that are specified as a comma separated list in the //wikis// parameter. If //className// is specified, the result will also contain the data for the first object of the corresponding class.
260 *** [before 6.4] using a Lucene query (handled by the [[Lucene Plugin>>extensions:Extension.Lucene Plugin]]) on the wikis that are specified as a comma separated list in the //wikis// parameter. If //className// is specified, the result will also contain the data for the first object of the corresponding class.
Fabio Mancinelli 38.1 261 ** **Status codes:**
262 *** 200: If the request was successful.
263
Manuel Smeria 40.7 264 === /wikis/{wikiName} ===
Fabio Mancinelli 38.1 265
Fabio Mancinelli 38.2 266 * **HTTP Method:** GET
267 ** **Media types:**
268 *** application/xml (Wiki element)
269 ** **Description:** information about the wiki
270 ** **Status codes:**
271 *** 200: If the request was successful.
272
273 * **HTTP Method:** POST
274 ** **Accepted Media types:**
275 *** octet/stream (A XAR file)
276 ** **Media types:**
277 *** application/xml (Wiki element)
278 ** **Query parameters**
279 *** backup={true/false} - import XAR as a backup XAR
280 *** history={RESET/REPLACE/ADD} - history importing
Fabio Mancinelli 38.3 281 ** **Description:** import a XAR in a wiki.
Fabio Mancinelli 38.2 282 ** **Status codes:**
283 *** 200: If the request was successful.
284
Manuel Smeria 40.7 285 === /wikis/{wikiName}/search?q~={keywords}~[~[&scope~={name,content,title,objects}...]&start~=n][&number~=n][&orderField~=field&order~={asc,desc}][distinct~={true,false}][&prettyNames~={true,false}] ===
Fabio Mancinelli 38.1 286
287 * **HTTP Method:** GET
288 ** **Media types:**
289 *** application/xml (SearchResults element)
Silvia Macovei 9.1 290 ** **Description:** The list of pages and objects that contain the {keywords} in the specified {scope}s. Multiple scopes can be specified. Search results are relative to the whole {wikiName}
291 ** **Status codes:**
Fabio Mancinelli 1.1 292 *** 200: If the request was successful.
293
Thomas Mortagne 41.1 294 === /wikis/{wikiName}/query?q~={query}&type~={hql,xwql,lucene,solr}[&distinct~={true,false}]~~[&order~={asc,desc}][&start~=n][&number~=n][&prettyNames~={true,false}][&className~=className] ===
Fabio Mancinelli 38.1 295
296 * **HTTP Method:** GET
297 ** **Media types:**
298 *** application/xml (SearchResults element)
Thomas Mortagne 42.1 299 ** **Description:** Allow to execute HQL, XWQL, Lucene or SOLR queries on the given {wikiName}. The //q// parameter contains the corresponding query. See [[HQL Query Examples in Velocity>>platform:DevGuide.velocityHqlExamples]], [[XWiki Query Language Specification>>dev:Design.XWiki Query Language Specification]], [[Lucene Plugin>>extensions:Extension.Lucene Plugin]] and [[SOLR query API>>extensions:Extension.Solr Search Query API]] examples of the queries that can be specified in this parameter. If //className// is specified, the result will also contain the data for the first object of the corresponding class.
Fabio Mancinelli 38.1 300 ** **Status codes:**
301 *** 200: If the request was successful.
302
Manuel Smeria 40.7 303 === /wikimanager (This resource is only available when using XWiki Enterprise Manager) ===
Fabio Mancinelli 38.3 304
305 * **HTTP Method:** POST
306 ** **Accepted Media types:**
307 *** application/xml (Wiki element)
308 ** **Media types:**
309 *** application/xml (Wiki element)
310 ** **Query parameters**
311 *** template - the wiki template to be used for initializing the wiki.
312 *** history={RESET/REPLACE/ADD} - history importing
313 ** **Description:** create a new wiki.
314 ** **Status codes:**
315 *** 200: If the request was successful.
316
Vincent Massol 14.2 317 == Space resources ==
Fabio Mancinelli 1.1 318
Vincent Massol 14.2 319 === /wikis/{wikiName}/spaces[?start~=offset&number~=n] ===
Silvia Macovei 9.1 320
321 * **HTTP Method:** GET
322 ** **Media types:**
Fabio Mancinelli 1.1 323 *** application/xml (Spaces element)
Silvia Macovei 9.1 324 ** **Description:** Retrieves the list of spaces available in the {wikiName} wiki.
325 ** **Status codes:**
Fabio Mancinelli 1.1 326 *** 200: If the request was successful.
327
Jerome 20.1 328 === /wikis/{wikiName}/spaces/{spaceName}/search?q~={keywords}~[~[&scope~={name,content,title,objects}...]&number~=n] ===
Silvia Macovei 9.1 329
330 * **HTTP Method:** GET
331 ** **Media types:**
Fabio Mancinelli 1.1 332 *** application/xml (Search results element)
Silvia Macovei 9.1 333 ** **Description:** The list of pages and objects that contain the {keywords} in the specified {scope}s. Multiple scopes can be specified. Search results are relative to space {spaceName}
334 ** **Status codes:**
Fabio Mancinelli 1.1 335 *** 200: If the request was successful.
336 *** 401: If the user is not authorized.
337
Vincent Massol 14.2 338 == Page resources ==
Fabio Mancinelli 1.1 339
Vincent Massol 14.2 340 === /wikis/{wikiName}/spaces/{spaceName}/pages[?start~=offset&number~=n] ===
Silvia Macovei 9.1 341
342 * **HTTP Method:** GET
343 ** **Media types:**
Fabio Mancinelli 1.1 344 *** application/xml (Pages element)
Silvia Macovei 9.1 345 ** **Description:** The list of pages in the space {spaceName}
346 ** **Status codes:**
Eduard Moraru 31.1 347 *** 200: If the request was successful.
Fabio Mancinelli 1.1 348 *** 401: If the user is not authorized.
349
Vincent Massol 14.2 350 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName} ===
Silvia Macovei 9.1 351
352 * **HTTP Method:** GET
353 ** **Media types:**
Fabio Mancinelli 1.1 354 *** application/xml (Page element)
Silvia Macovei 9.1 355 ** **Description:**
356 ** **Status codes:**
Fabio Mancinelli 1.1 357 *** 200: If the request was successful.
358 *** 401: If the user is not authorized.
Silvia Macovei 9.1 359
360 \\
361
362 * **HTTP Method:** PUT
363 ** **Accepted Media types:**
Fabio Mancinelli 1.1 364 *** application/xml (Page element)
365 *** text/plain (Only page content)
366 *** application/x-www-form-urlencoded (allowed field names: title, parent, content)
Silvia Macovei 9.1 367 ** **Media types:**
Fabio Mancinelli 1.1 368 *** application/xml (Page element)
Silvia Macovei 9.1 369 ** **Description:** Create or updates a page.
370 ** **Status codes:**
Fabio Mancinelli 1.1 371 *** 201: If the page was created.
372 *** 202: If the page was updated.
373 *** 304: If the page was not modified.
374 *** 401: If the user is not authorized.
Silvia Macovei 9.1 375
376 \\
377
378 * **HTTP Method:** DELETE
379 ** **Media types:**
Fabio Mancinelli 1.1 380 *** application/xml (Page element)
Silvia Macovei 9.1 381 ** **Description:** Delete the page.
382 ** **Status codes:**
Fabio Mancinelli 1.1 383 *** 204: If the request was successful.
384 *** 401: If the user is not authorized.
385
Vincent Massol 14.2 386 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/history[?start~=offset&number~=n] ===
Silvia Macovei 9.1 387
388 * **HTTP Method:** GET
389 ** **Media types:**
Fabio Mancinelli 1.1 390 *** application/xml (History element)
Silvia Macovei 9.1 391 ** **Description:** The list of all the versions of the given page.
392 ** **Status codes:**
Fabio Mancinelli 1.1 393 *** 200: If the request was successful.
394 *** 401: If the user is not authorized.
395
Vincent Massol 14.2 396 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/history/{version} ===
Silvia Macovei 9.1 397
398 * **HTTP Method:** GET
399 ** **Media types:**
Fabio Mancinelli 1.1 400 *** application/xml (Page element)
Silvia Macovei 9.1 401 ** **Description:** The page at version {version}
402 ** **Status codes:**
Fabio Mancinelli 1.1 403 *** 200: If the request was successful.
404 *** 401: If the user is not authorized.
405
Silvia Macovei 10.1 406 ==== /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/translations[?start~=offset&number~=n] ====
Silvia Macovei 9.1 407
408 * **HTTP Method:** GET
409 ** **Media types:**
Fabio Mancinelli 1.1 410 *** application/xml (Translations element)
Silvia Macovei 9.1 411 ** **Description:** The list of available translation for the page
412 ** **Status codes:**
Fabio Mancinelli 1.1 413 *** 200: If the request was successful.
414 *** 401: If the user is not authorized.
415
Vincent Massol 14.2 416 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/translations/{language} ===
Silvia Macovei 9.1 417
418 * **HTTP Method:** GET
419 ** **Media types:**
Fabio Mancinelli 1.1 420 *** application/xml (Page element)
Silvia Macovei 9.1 421 ** **Description:** The page at in the given {language}.
422 ** **Status codes:**
Fabio Mancinelli 1.1 423 *** 200: If the request was successful.
424 *** 401: If the user is not authorized.
Silvia Macovei 9.1 425
426 \\
427
428 * **HTTP Method:** PUT
429 ** **Accepted Media types:**
Fabio Mancinelli 1.1 430 *** application/xml (Page element)
431 *** text/plain (Only page content)
432 *** application/x-www-form-urlencoded (allowed field names: title, parent, content)
Silvia Macovei 9.1 433 ** **Media types:**
Fabio Mancinelli 1.1 434 *** application/xml (Page element)
Silvia Macovei 9.1 435 ** **Description:** Create or updates a page translation.
436 ** **Status codes:**
Fabio Mancinelli 1.1 437 *** 201: If the page was created.
438 *** 202: If the page was updated.
439 *** 304: If the page was not modified.
440 *** 401: If the user is not authorized.
Silvia Macovei 9.1 441
442 \\
443
444 * **HTTP Method:** DELETE
445 ** **Media types:**
Fabio Mancinelli 1.1 446 *** application/xml (Page element)
Silvia Macovei 9.1 447 ** **Description:** Delete the page translation.
448 ** **Status codes:**
Fabio Mancinelli 1.1 449 *** 204: If the request was successful.
450 *** 401: If the user is not authorized.
451
Vincent Massol 14.2 452 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/translations/{language}/history ===
Silvia Macovei 9.1 453
454 * **HTTP Method:** GET
455 ** **Media types:**
Fabio Mancinelli 1.1 456 *** application/xml (History element)
Silvia Macovei 9.1 457 ** **Description:** The list of all the available revisions of the page in a given {language}.
458 ** **Status codes:**
Fabio Mancinelli 1.1 459 *** 200: If the request was successful.
460 *** 401: If the user is not authorized.
461
Vincent Massol 14.2 462 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/translations/{lang}/history/{version} ===
Silvia Macovei 9.1 463
464 * **HTTP Method:** GET
465 ** **Media types:**
Fabio Mancinelli 1.1 466 *** application/xml (Page element)
Silvia Macovei 9.1 467 ** **Description:** A page at a given {version} in a given {language}.
468 ** **Status codes:**
Fabio Mancinelli 1.1 469 *** 200: If the request was successful.
470 *** 401: If the user is not authorized.
471
Vincent Massol 14.2 472 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/children ===
Silvia Macovei 9.1 473
474 * **HTTP Method:** GET
475 ** **Media types:**
Fabio Mancinelli 1.1 476 *** application/xml (Pages element)
Silvia Macovei 9.1 477 ** **Description:** The list of the children of a given page.
478 ** **Status codes:**
Fabio Mancinelli 1.1 479 *** 200: If the request was successful.
480 *** 401: If the user is not authorized.
481
Eduard Moraru 31.1 482 === /wikis/{wikiName}/pages[?name~=paneName&space~=spaceName&author~=authorName] ===
483
484 * **HTTP Method:** GET
485 ** **Media types:**
486 *** application/xml (Pages element)
487 ** **Description:** The list of pages in the wiki {wikiName}. Filters can be set for the name, space and/or author to include only pages that match the given filters. This resource can be used to search for pages in a wiki.
488 ** **Status codes:**
489 *** 200: If the request was successful.
490 *** 401: If the user is not authorized.
491
Vincent Massol 14.2 492 == Tag resources ==
Fabio Mancinelli 1.1 493
Vincent Massol 14.2 494 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/tags ===
Silvia Macovei 9.1 495
496 * **HTTP Method:** GET
497 ** **Media types:**
Fabio Mancinelli 1.1 498 *** application/xml (Tags element)
Silvia Macovei 9.1 499 ** **Description:** List page tags.
500 ** **Status codes:**
Fabio Mancinelli 1.1 501 *** 200: If the request was successful.
502 *** 401: If the user is not authorized.
Silvia Macovei 9.1 503
504 \\
505
506 * **HTTP Method:** PUT
507 ** **Accepted Media types:**
Fabio Mancinelli 1.1 508 *** application/xml (Tag element)
509 *** text/plain
510 *** application/x-www-form-urlencoded (allowed field names: tag)
Silvia Macovei 9.1 511 ** **Media types:**
Fabio Mancinelli 1.1 512 *** application/xml (Tags element)
Silvia Macovei 9.1 513 ** **Description:** Add a tag to the page.
514 ** **Status codes:**
Fabio Mancinelli 1.1 515 *** 202: If the request was successful.
516 *** 401: If the user is not authorized.
517
Vincent Massol 14.2 518 === /wikis/{wikiName}/tags ===
Silvia Macovei 9.1 519
520 * **HTTP Method:** GET
521 ** **Media types:**
Fabio Mancinelli 1.1 522 *** application/xml (Tags element)
Silvia Macovei 9.1 523 ** **Description:** The list of all available tags
524 ** **Status codes:**
Fabio Mancinelli 1.1 525 *** 200: If the request was successful.
526 *** 401: If the user is not authorized.
527
Vincent Massol 14.2 528 === /wikis/{wikiName}/tags/{tag1}[,{tag2},{tag3}...][?start~=offset&number~=n] ===
Silvia Macovei 9.1 529
530 * **HTTP Method:** GET
531 ** **Media types:**
Fabio Mancinelli 1.1 532 *** application/xml (Pages element)
Silvia Macovei 9.1 533 ** **Description:** The list of pages having the specified tags.
534 ** **Status codes:**
Fabio Mancinelli 1.1 535 *** 200: If the request was successful.
536 *** 401: If the user is not authorized.
537
Vincent Massol 14.2 538 == Comments resources ==
Fabio Mancinelli 1.1 539
Vincent Massol 14.2 540 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/comments[?start~=offset&number~=n] ===
Silvia Macovei 9.1 541
542 * **HTTP Method:** GET
543 ** **Media types:**
Fabio Mancinelli 1.1 544 *** application/xml (Comments element)
Silvia Macovei 9.1 545 ** **Description:** The list of comments on a given page.
546 ** **Status codes:**
Fabio Mancinelli 1.1 547 *** 200: If the request was successful.
548 *** 401: If the user is not authorized.
Silvia Macovei 9.1 549
550 \\
551
552 * **HTTP Method:** POST
553 ** **Accepted Media types:**
Fabio Mancinelli 1.1 554 *** application/xml (Comment element)
555 *** text/plain
Jerome 20.1 556 *** application/x-www-form-urlencoded - allowed field names: ##text##, ##replyTo## (object number of the replied comment, since XE 2.3)
Silvia Macovei 9.1 557 ** **Media types:**
Fabio Mancinelli 1.1 558 *** application/xml (Comment element)
Silvia Macovei 9.1 559 ** **Description:** Create a comment on the given page.
560 ** **Status codes:**
Fabio Mancinelli 1.1 561 *** 201: If the comment was created. (The Location header will contain the URI where the comment has been created.)
562 *** 401: If the user is not authorized.
563
Vincent Massol 14.2 564 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/comments/{commentId} ===
Silvia Macovei 9.1 565
566 * **HTTP Method:** GET
567 ** **Media types:**
Fabio Mancinelli 1.1 568 *** application/xml (Comment element)
Silvia Macovei 9.1 569 ** **Description:** A specific comment on a page
570 ** **Status codes:**
Fabio Mancinelli 1.1 571 *** 200: If the request was successful.
572 *** 401: If the user is not authorized.
573
Vincent Massol 14.2 574 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/history/{version}/comments ===
Silvia Macovei 9.1 575
576 * **HTTP Method:** GET
577 ** **Media types:**
Fabio Mancinelli 1.1 578 *** application/xml (Comments element)
Silvia Macovei 9.1 579 ** **Description:** The list of comments at a specific page {version}.
580 ** **Status codes:**
Fabio Mancinelli 1.1 581 *** 200: If the request was successful.
582 *** 401: If the user is not authorized.
583
Vincent Massol 14.2 584 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/history/{version}/comments/{commentId} ===
Silvia Macovei 9.1 585
586 * **HTTP Method:** GET
587 ** **Media types:**
Fabio Mancinelli 1.1 588 *** application/xml (Comment element)
Silvia Macovei 9.1 589 ** **Description:** A comment at a specific page {version}.
590 ** **Status codes:**
Fabio Mancinelli 1.1 591 *** 200: If the request was successful.
592 *** 401: If the user is not authorized.
593
Vincent Massol 14.2 594 == Attachments resources ==
Fabio Mancinelli 1.1 595
Vincent Massol 14.2 596 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/attachments[?start~=offset&number~=n] ===
Silvia Macovei 9.1 597
598 * **HTTP Method:** GET
599 ** **Media types:**
Fabio Mancinelli 1.1 600 *** application/xml (Attachments element)
Silvia Macovei 9.1 601 ** **Description:** The list of attachments of a given page.
602 ** **Status codes:**
Fabio Mancinelli 1.1 603 *** 200: If the request was successful.
604 *** 401: If the user is not authorized.
605
Eduard Moraru 29.2 606 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/attachments/{attachmentName} ===
Silvia Macovei 9.1 607
608 * **HTTP Method:** GET
609 ** **Media types:**
Fabio Mancinelli 1.1 610 *** The same of the attachment media type.
Silvia Macovei 9.1 611 ** **Description:** The attachment identified by {attachmentName} on a given page.
612 ** **Status codes:**
Fabio Mancinelli 1.1 613 *** 200: If the request was successful.
614 *** 401: If the user is not authorized.
Silvia Macovei 9.1 615
616 \\
617
618 * **HTTP Method:** PUT
619 ** **Accepted media types:**
620 *** **/**
621 ** **Media types:**
Fabio Mancinelli 1.1 622 *** application/xml (AttachmentSummary element)
Silvia Macovei 9.1 623 ** **Description:** Create an attachment identified by {attachmentName} on a given page.
624 ** **Status codes:**
Fabio Mancinelli 1.1 625 *** 201: If the attachment was created.
626 *** 202: If the attachment was updated.
627 *** 401: If the user is not authorized.
Silvia Macovei 9.1 628
629 \\
630
631 * **HTTP Method:** DELETE
632 ** **Media types:**
633 ** **Description:** Delete the attachment identified by {attachmentName} on a given page.
634 ** **Status codes:**
Fabio Mancinelli 1.1 635 *** 204: If the attachment was deleted.
636 *** 401: If the user is not authorized.
637
Vincent Massol 14.2 638 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/history/{version}/attachments[?start~=offset&number~=n] ===
Silvia Macovei 9.1 639
640 * **HTTP Method:** GET
641 ** **Media types:**
Fabio Mancinelli 1.1 642 *** application/xml (Attachments element)
Silvia Macovei 9.1 643 ** **Description:** The list of attachments at a given page {version}.
644 ** **Status codes:**
Fabio Mancinelli 1.1 645 *** 200: If the request was successful.
646 *** 401: If the user is not authorized.
647
Vincent Massol 14.2 648 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/history/{version}/attachments/{attachmentName} ===
Silvia Macovei 9.1 649
650 * **HTTP Method:** GET
651 ** **Media types:**
Fabio Mancinelli 1.1 652 *** The same of the attachment media type.
Silvia Macovei 9.1 653 ** **Description:** The attachment identified by {attachmentName} on a given page {version}.
654 ** **Status codes:**
Fabio Mancinelli 1.1 655 *** 200: If the request was successful.
656 *** 401: If the user is not authorized.
657
Vincent Massol 14.2 658 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/attachments/{attachmentName}/history ===
Silvia Macovei 9.1 659
660 * **HTTP Method:** GET
661 ** **Media types:**
Chamika Weerasinghe 28.6 662 *** application/xml (Attachments element)
Silvia Macovei 9.1 663 ** **Description:** The list of available version for the {attachmentName}
664 ** **Status codes:**
Fabio Mancinelli 1.1 665 *** 200: If the request was successful.
666 *** 401: If the user is not authorized.
667
Vincent Massol 14.2 668 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/attachments/{attachmentName}/history/{version} ===
Silvia Macovei 9.1 669
670 * **HTTP Method:** GET
671 ** **Media types:**
Fabio Mancinelli 1.1 672 *** The same of the attachment media type.
Silvia Macovei 9.1 673 ** **Description:** The {attachmentName} at a given {version}
674 ** **Status codes:**
Fabio Mancinelli 1.1 675 *** 200: If the request was successful.
676 *** 401: If the user is not authorized.
677
Eduard Moraru 30.1 678 === /wikis/{wikiName}/spaces/{spaceName}/attachments[?name~=attachmentName&page~=pageName&author~=authorName&types~=attachmentTypeList&start~=offset&number~=n] ===
679
680 * **HTTP Method:** GET
681 ** **Media types:**
682 *** application/xml (Attachments element)
Eduard Moraru 31.2 683 ** **Description:** The list of attachments of pages located in a given {spaceName}. Filters can be set for the name, page, author and/or types (comma separated list of strings) to include only attachments that match the given filters. This resource can be used to search for attachments in a space.
Eduard Moraru 30.1 684 ** **Status codes:**
685 *** 200: If the request was successful.
686 *** 401: If the user is not authorized.
687
Eduard Moraru 30.2 688 === /wikis/{wikiName}/attachments[?name~=attachmentName&page~=pageName&space~=spaceName&author~=authorName&types~=attachmentTypeList&start~=offset&number~=n] ===
Eduard Moraru 30.1 689
690 * **HTTP Method:** GET
691 ** **Media types:**
692 *** application/xml (Attachments element)
Eduard Moraru 31.2 693 ** **Description:** The list of attachments in a given {wikiName}. Filters can be set for the name, page, space, author and/or type (comma separated list of strings) to include only attachments that match the given filters. This resource can be used to search for attachments in a wiki.
Eduard Moraru 30.1 694 ** **Status codes:**
695 *** 200: If the request was successful.
696 *** 401: If the user is not authorized.
697
Vincent Massol 14.2 698 == Object resources ==
Fabio Mancinelli 1.1 699
Vincent Massol 14.2 700 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/objects[?start~=offset&number~=n] ===
Silvia Macovei 9.1 701
702 * **HTTP Method:** GET
703 ** **Media types:**
Fabio Mancinelli 1.1 704 *** application/xml (Objects element)
Silvia Macovei 9.1 705 ** **Description:** The list of objects associated to a page.
706 ** **Status codes:**
Fabio Mancinelli 1.1 707 *** 200: If the request was successful.
708 *** 401: If the user is not authorized.
Silvia Macovei 9.1 709
710 \\
711
712 * **HTTP Method:** POST
713 ** **Accepted media types:**
Fabio Mancinelli 1.1 714 *** application/xml (Object element)
Anca Luca 29.1 715 *** application/x-www-form-urlencoded (a set of property#name=value pairs representing properties and a field className)
Silvia Macovei 9.1 716 ** **Media types:**
717 *** application/xml (Object element)
718 ** **Description:** Create a new object.
719 ** **Status codes:**
Fabio Mancinelli 1.1 720 *** 201: If the object was created (The Location header will contain the URI associated to the newly created object).
721 *** 401: If the user is not authorized.
722
Vincent Massol 14.2 723 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/objects/{className}[?start~=offset&number~=n] ===
Silvia Macovei 9.1 724
725 * **HTTP Method:** GET
726 ** **Media types:**
Fabio Mancinelli 1.1 727 *** application/xml (Objects element)
Silvia Macovei 9.1 728 ** **Description:** The list of objects of a given {className} associated to a page.
729 ** **Status codes:**
Fabio Mancinelli 1.1 730 *** 200: If the request was successful.
731 *** 401: If the user is not authorized.
732
Vincent Massol 14.2 733 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/objects/{className}/{objectNumber} ===
Silvia Macovei 9.1 734
735 * **HTTP Method:** GET
736 ** **Media types:**
Fabio Mancinelli 1.1 737 *** application/xml (Object element)
Silvia Macovei 9.1 738 ** **Description:** The object of type {className} identified by {objectNumber} associated to the given page.
739 ** **Status codes:**
Fabio Mancinelli 1.1 740 *** 200: If the request was successful.
741 *** 401: If the user is not authorized.
Silvia Macovei 9.1 742
743 \\
744
745 * **HTTP Method:** PUT
746 ** **Accepted media types:**
Fabio Mancinelli 1.1 747 *** application/xml (Object element)
Anca Luca 29.1 748 *** application/x-www-form-urlencoded (a set of property#name=value pairs representing properties)
Silvia Macovei 9.1 749 ** **Media types:**
750 *** application/xml (Object element)
751 ** **Description:** Modify the object properties.
752 ** **Status codes:**
Fabio Mancinelli 1.1 753 *** 202: If the object was updated.
754 *** 401: If the user is not authorized.
Silvia Macovei 9.1 755
756 \\
757
758 * **HTTP Method:** DELETE
759 ** **Media types:**
760 ** **Description:** Delete the object.
761 ** **Status codes:**
Fabio Mancinelli 1.1 762 *** 204: If the object was deleted.
763 *** 401: If the user is not authorized.
764
Vincent Massol 14.2 765 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/objects/{className}/{objectNumber}/properties ===
Silvia Macovei 9.1 766
767 * **HTTP Method:** GET
768 ** **Media types:**
Fabio Mancinelli 1.1 769 *** application/xml (Properties element)
Silvia Macovei 9.1 770 ** **Description:** The properties of the object of type {className} identified by {objectNumber} associated to the given page.
771 ** **Status codes:**
Fabio Mancinelli 1.1 772 *** 200: If the request was successful.
773 *** 401: If the user is not authorized.
774
Vincent Massol 14.2 775 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/objects/{className}/{objectNumber}/properties/{propertyName} ===
Silvia Macovei 9.1 776
777 * **HTTP Method:** GET
778 ** **Media types:**
Fabio Mancinelli 1.1 779 *** application/xml (Properties element)
Silvia Macovei 9.1 780 ** **Description:** The property {propertyname} of the object of type {className} identified by {objectNumber} associated to the given page.
781 ** **Status codes:**
Fabio Mancinelli 1.1 782 *** 200: If the request was successful.
783 *** 401: If the user is not authorized.
Silvia Macovei 9.1 784
785 \\
786
787 * **HTTP Method:** PUT
788 ** **Accepted media types:**
Fabio Mancinelli 1.1 789 *** application/xml (Property element)
790 *** text/plain
Anca Luca 29.1 791 *** application/x-www-form-urlencoded (a field property#name=value pairs representing a property)
Silvia Macovei 9.1 792 ** **Media types:**
793 *** application/xml (Property element)
794 ** **Description:** Modify the object properties.
795 ** **Status codes:**
Fabio Mancinelli 1.1 796 *** 202: If the object was updated.
797 *** 401: If the user is not authorized.
798
Vincent Massol 14.2 799 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/history/{version}/objects[?start~=offset&number~=n] ===
Silvia Macovei 9.1 800
801 * **HTTP Method:** GET
802 ** **Media types:**
Fabio Mancinelli 1.1 803 *** application/xml (Objects element)
Silvia Macovei 9.1 804 ** **Description:** The list of objects associated to a page at a given {version}.
805 ** **Status codes:**
Fabio Mancinelli 1.1 806 *** 200: If the request was successful.
807 *** 401: If the user is not authorized.
808
Vincent Massol 14.2 809 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/history/{version}/objects/{className}/{objectNumber} ===
Silvia Macovei 9.1 810
811 * **HTTP Method:** GET
812 ** **Media types:**
Fabio Mancinelli 1.1 813 *** application/xml (Object element)
Silvia Macovei 9.1 814 ** **Description:** The object of type {className} identified by {objectNumber} associated to the given page at a given {version}.
815 ** **Status codes:**
Fabio Mancinelli 1.1 816 *** 200: If the request was successful.
817 *** 401: If the user is not authorized.
818
Vincent Massol 14.2 819 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/history/{version}/objects/{className}/{objectNumber}/properties ===
Silvia Macovei 9.1 820
821 * **HTTP Method:** GET
822 ** **Media types:**
Fabio Mancinelli 1.1 823 *** application/xml (Properties element)
Silvia Macovei 9.1 824 ** **Description:** The properties of the object of type {className} identified by {objectNumber} associated to the given page at a given {version}.
825 ** **Status codes:**
Fabio Mancinelli 1.1 826 *** 200: If the request was successful.
827 *** 401: If the user is not authorized.
828
Vincent Massol 14.2 829 === /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/history/{version}/objects/{className}/{objectNumber}/properties/{propertyName} ===
Silvia Macovei 9.1 830
831 * **HTTP Method:** GET
832 ** **Media types:**
Fabio Mancinelli 1.1 833 *** application/xml (Properties element)
Silvia Macovei 9.1 834 ** **Description:** The property {propertyname} of the object of type {className} identified by {objectNumber} associated to the given page at a given {version}.
835 ** **Status codes:**
Fabio Mancinelli 1.1 836 *** 200: If the request was successful.
837 *** 401: If the user is not authorized.
838
Vincent Massol 14.2 839 === /wikis/{wikiName}/class/{className}/objects ===
Silvia Macovei 9.1 840
841 * **HTTP Method:** GET
842 ** **Media types:**
Fabio Mancinelli 1.1 843 *** application/xml (Objects element)
Silvia Macovei 9.1 844 ** **Description:** The list of all the objects of a given {className}.
845 ** **Status codes:**
Fabio Mancinelli 1.1 846 *** 200: If the request was successful.
847 *** 401: If the user is not authorized.
848
Vincent Massol 14.2 849 == Class resources ==
Fabio Mancinelli 1.1 850
Vincent Massol 14.2 851 === /wikis/{wikiName}/classes[?start~=offset&number~=n] ===
Silvia Macovei 9.1 852
853 * **HTTP Method:** GET
854 ** **Media types:**
Fabio Mancinelli 1.1 855 *** application/xml (Classes element)
Silvia Macovei 9.1 856 ** **Description:** The list of all the classes defined in the wiki {wikiName}
857 ** **Status codes:**
Fabio Mancinelli 1.1 858 *** 200: If the request was successful.
859 *** 401: If the user is not authorized.
860
Vincent Massol 14.2 861 === /wikis/{wikiName}/classes/{className} ===
Silvia Macovei 9.1 862
863 * **HTTP Method:** GET
864 ** **Media types:**
Fabio Mancinelli 1.1 865 *** application/xml (Class element)
Silvia Macovei 9.1 866 ** **Description:** The {className} definition
867 ** **Status codes:**
Fabio Mancinelli 1.1 868 *** 200: If the request was successful.
869 *** 401: If the user is not authorized.
870
Vincent Massol 14.2 871 === /wikis/{wikiName}/classes/{className}/properties ===
Silvia Macovei 9.1 872
873 * **HTTP Method:** GET
874 ** **Media types:**
Fabio Mancinelli 1.1 875 *** application/xml (Properties element)
Silvia Macovei 9.1 876 ** **Description:** The properties of the class {className}.
877 ** **Status codes:**
Fabio Mancinelli 1.1 878 *** 200: If the request was successful.
879 *** 401: If the user is not authorized.
880
Vincent Massol 14.2 881 === /wikis/{wikiName}/classes/{className}/properties/{property} ===
Silvia Macovei 9.1 882
883 * **HTTP Method:** GET
884 ** **Media types:**
Fabio Mancinelli 1.1 885 *** application/xml (Property element)
Silvia Macovei 9.1 886 ** **Description:** The property {property} of the class {className}.
887 ** **Status codes:**
Fabio Mancinelli 1.1 888 *** 200: If the request was successful.
889 *** 401: If the user is not authorized.
890
Vincent Massol 14.2 891 == Other resources ==
Fabio Mancinelli 1.1 892
Ludovic Dubost 21.1 893 === /wikis/{wikiName}/modifications[?start~=offset&number~=n&date~=t] ===
Silvia Macovei 9.1 894
895 * **HTTP Method:** GET
896 ** **Media types:**
Fabio Mancinelli 1.1 897 *** application/xml (Modifications element)
Silvia Macovei 9.1 898 ** **Description:** The list of the latest modification made to the wiki {wikiName} starting from time t (t is expressed in milliseconds from 1970 of the starting date)
899 ** **Status codes:**
Fabio Mancinelli 1.1 900 *** 200: If the request was successful.
901 *** 401: If the user is not authorized.
Thomas Mortagne 22.1 902
903 = Custom resources =
904
Thomas Mortagne 24.1 905 It's possible to easily add any REST resource by registering a ##org.xwiki.rest.XWikiResource## java component on your wiki (see [[Component guide>>DevGuide.WritingComponents]] for more details).
Thomas Mortagne 22.1 906
Thomas Mortagne 23.1 907 {{code language="java"}}
Thomas Mortagne 22.1 908 package org.xwiki.contrib.rest;
909
910 import javax.ws.rs.DefaultValue;
911 import javax.ws.rs.GET;
912 import javax.ws.rs.Path;
913
914 import org.xwiki.component.annotation.Component;
915 import org.xwiki.rest.XWikiResource;
916
917 @Component("org.xwiki.contrib.rest.HelloWordResource")
918 @Path("/myresources/{myresourcename}")
919 class HelloWorldResource extends XWikiResource {
920 @GET
921 public String get(@PathParam("myresourcename") @DefaultValue("world") String myresourcename)
922 {
923 return "Hello " + myresourcename;
924 }
925 }
Thomas Mortagne 23.1 926 {{/code}}
Thomas Mortagne 22.1 927
928 The name of the component has to be the class FQN.
929
Manuel Smeria 40.8 930 You can find more examples on [[this page>>https://github.com/xwiki/xwiki-platform/tree/master/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-server/src/main/java/org/xwiki/rest]].
Fabio Mancinelli 34.1 931
Fabio Mancinelli 40.1 932 Starting from release 4.3M2, the RESTful API modules have been refactored so that now resource declarations are available in a separate module.
933 This means that all the information about resources, i.e., URI Paths, supported methods, query parameters, and so on, are available to module developers without having to include the big REST Server module.
934
935 Clients willing to access/use the REST API can then declare a dependency on xwiki-platform-rest-api and have all this information available for interacting with it. There are two use cases for this:
Manuel Smeria 40.7 936
Fabio Mancinelli 40.1 937 * Another platform module that wants to generate responses with links to existing resources.
938 * HTTP clients that wants to make requests to the RESTful API.
939
940 The xwiki-platform-rest-api module can be also seen as an authoritative reference for the REST API.
941
Fabio Mancinelli 34.1 942 = Using the RESTful API =
943
944 == Highlevel description and tutorial for a basic usage of the RESTful API ==
945
Manuel Smeria 40.7 946 See [[this tutorial>>http://blog.fabio.mancinelli.me/2011/03/07/XWikis_RESTful_API.html]] by Fabio Mancinelli.
Fabio Mancinelli 34.1 947
Fabio Mancinelli 35.1 948 == Creating an XWiki Object ==
Fabio Mancinelli 34.1 949
950 In this example we will use the [[curl>>http://curl.haxx.se/]] utility as the HTTP client.
951
Fabio Mancinelli 36.1 952 Imagine that you want to create on the page Test.Test a new object of the class XWiki.TestClass, supposing that the class has a property called ##text##.
Fabio Mancinelli 34.1 953
954 So, on the command line, you have to do the following:
955
956 {{code}}
957 $ curl -u Admin:admin
958 -X POST
959 -H "Content-type: application/xml"
960 -H "Accept: application/xml"
961 -d "@test.xml"
962 http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects
963 {{/code}}
964
965 where ##test.xml## is:
966
967 {{code language="xml"}}
968 <object xmlns="http://www.xwiki.org">
969 <className>XWiki.TestClass</className>
Fabio Mancinelli 37.1 970 <property name="text">
Fabio Mancinelli 34.1 971 <value>Whatever you want to put here</value>
972 </property>
973 </object>
974 {{/code}}
975
976 Alternatively you can use the less verbose ##application/x-www-form-urlencoded format##:
977
978 {{code}}
979 $ curl -u Admin:admin
980 -X POST
981 -H "Content-type: application/x-www-form-urlencoded"
982 -H "Accept: application/xml"
983 -d "@test.txt"
984 http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects
985 {{/code}}
986
987 where ##test.txt## contains something like:
988
989 {{code}}
Fabio Mancinelli 37.1 990 className=XWiki.TestClass&property#test=Whatever+you+want
Fabio Mancinelli 34.1 991 {{/code}}
992
993 Or, better, you can use directly curl to specify these parameters
994 using multiple ##-d## switches:
995
996 {{code}}
997 $ curl -u Admin:admin
998 -X POST -H "Content-type: application/x-www-form-urlencoded"
999 -H "Accept: application/xml"
1000 -d "className=XWiki.TestClass"
Fabio Mancinelli 37.1 1001 -d "property#test=Whatever you want"
Fabio Mancinelli 34.1 1002 http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects
1003 {{/code}}
1004
1005 The advantage of the second approach is that curl will take care of url-encode your content, while if you send a file you are responsible for this.
1006
Manuel Smeria 40.7 1007 === Remarks: ===
Fabio Mancinelli 34.1 1008
Manuel Smeria 40.7 1009 * In the ##application/x-www-form-urlencoded## format the "property#" is a standard immutable prefix that is used to distinguish attributes referring to property values from the attributes referring to the object. For example if we had ##className=XYZ&Text=FOO## we would have had an ambiguity on ##className## because we couldn't understand if ##className## is a property of the object to be set to XYZ or an attribute that describes the object itself (i.e., its metadata like the ##className##). By having the ##property### prefix this ambiguity is resolved.
Fabio Mancinelli 34.1 1010
1011 * The information you get back when you retrieve an object (i.e., all
1012 the ##<attribute>## elements) are useful when clients need to understand the type of data contained in an object (e.g., when they want to display it). They are not necessary when creating an object because the system already has this information. That's why the XML to be sent is smaller. Actually the only information needed is the ##<className>## and a set of ##<property name="..."><value>## elements.
1013
Manuel Smeria 40.7 1014 * How do you know what kind of information you can send with the XML? You can discover it by using the class description URI. If you go to ##http:~/~/localhost:8080/xwiki/rest/wikis/xwiki/classes ## you will get a list of all the classes defined in the Wiki. By looking at this you will understand what are the properties defined by each class, their types and attributes. In that way you will know what you're allowed to put in the ##<property><value>## elements of the XML you send.

Get Connected