Wiki source code of REST API

Last modified by Vincent Massol on 2025/02/17

Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc depth="2"/}}
3 {{/box}}
4
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.
6
7 = Accessing the service =
8
9 By defaut the XWiki RESTful API entrypoint is rooted at the following URI:
10
11 {{code}}
12 https://<host>:<port>/<context>/rest
13 {{/code}}
14
15 Where:
16 * ##host## and ##port## are the domain and port where XWiki is installed
17 * ##context## is the Servlet Context under which XWiki is deployed in the Servlet container. By default the value is ##xwiki##, and if XWiki is installed as a "root" web application as in theĀ [[official Docker image>>https://hub.docker.com/_/xwiki/]], the value is empty (and the REST API is then available at {{code language="none"}}https://<host>:<port>/rest{{/code}}).
18
19 All the resource references described in the [[XWiki RESTful API Documentation>>#HXWikiRESTfulAPIDocumentation]] should be intended relative to this URL.
20
21 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##
22
23 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 or by setting the ##Accept## header in the request to ##application/json##. For example:
24
25 * ##http:~/~/localhost:8080/xwiki/rest/wikis?media=json##
26 * ##curl -H 'Accept: application/json' https:~/~/www.xwiki.org/xwiki/rest/##
27
28 = Dataset =
29
30 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.
31
32 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.
33
34 = Understanding resources and representations =
35
36 "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]])
37
38 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]].
39
40 Of course the same resource can be represented in many different ways. This is yet to be documented.
41
42 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.
43
44 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.
45
46 [[image:representation||height="430"]]
47
48 == Relations ==
49
50 The available relations that you might find in the XML resource representations are the following:
51
52 |=Rel|=Semantics
53 |{{{http://www.xwiki.org/rel/wikis}}}|The representation containing the list of virtual wikis.
54 |{{{http://www.xwiki.org/rel/spaces}}}|The representation containing the list of spaces in a wiki.
55 |{{{http://www.xwiki.org/rel/pages}}}|The representation containing the list of pages in a space.
56 |{{{http://www.xwiki.org/rel/translation}}}|The representation containing a translation of a page.
57 |{{{http://www.xwiki.org/rel/page}}}|The representation for a page.
58 |{{{http://www.xwiki.org/rel/space}}}|The representation for a space.
59 |{{{http://www.xwiki.org/rel/parent}}}|The representation for the page that is parent of the current resource.
60 |{{{http://www.xwiki.org/rel/home}}}|The representation for the page that is the home of the current resource.
61 |{{{http://www.xwiki.org/rel/attachmentData}}}|The representation of the actual attachment data.
62 |{{{http://www.xwiki.org/rel/comments}}}|The representation of the list of comments associated to the current resource.
63 |{{{http://www.xwiki.org/rel/attachments}}}|The representation of the list of attachments associated to the current resource.
64 |{{{http://www.xwiki.org/rel/objects}}}|The representation of the list of objects associated to the current resource.
65 |{{{http://www.xwiki.org/rel/object}}}|The representation for an object.
66 |{{{http://www.xwiki.org/rel/classes}}}|The representation of the list of classes associated to the current resource.
67 |{{{http://www.xwiki.org/rel/history}}}|The representation of the list of history information associated to the current resource.
68 |{{{http://www.xwiki.org/rel/class}}}|The representation for a class.
69 |{{{http://www.xwiki.org/rel/property}}}|The representation for a property.
70 |{{{http://www.xwiki.org/rel/propertyValues}}}|The representation for the list of property values.
71 |{{{http://www.xwiki.org/rel/properties}}}|The representation of the list of properties associated to the current resource.
72 |{{{http://www.xwiki.org/rel/modifications}}}|The representation of the list of modifications associated to the current resource.
73 |{{{http://www.xwiki.org/rel/children}}}|The representation of the list of children associated to the current resource.
74 |{{{http://www.xwiki.org/rel/tags}}}|The representation of the list of tags associated to the current resource.
75 |{{{http://www.xwiki.org/rel/tag}}}|The representation of a tag.
76 |{{{http://www.xwiki.org/rel/search}}}|The representation for a search resource.
77 |{{{http://www.xwiki.org/rel/syntaxes}}}|The representation for a syntax resource.
78
79 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).
80
81 == The "HATEOAS" Graph ==
82
83 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.
84
85 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.
86
87 = Interacting with the XWiki RESTful API =
88
89 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!
90 If you want to write more complex programs you might download an HTTP library for your favorite language (e.g., [[http://hc.apache.org/]]), see [[this post>>xwiki:Blog.Use the Apache HTTP library to interact with the XWiki RESTful API]] by [[Mohamed Boussaa>>xwiki:XWiki.mouhb]].
91
92 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.
93
94 If you use this approach (Apache HTTP Client + JAXB) you will find yourself writing some code like this:
95
96 {{code language="java"}}
97 import javax.xml.bind.JAXBContext;
98 import javax.xml.bind.Unmarshaller;
99
100 import org.apache.commons.httpclient.HttpClient;
101 import org.apache.commons.httpclient.methods.GetMethod;
102 import org.xwiki.rest.model.jaxb.Page;
103
104 ...
105 HttpClient httpClient = new HttpClient();
106 JAXBContext context = JAXBContext.newInstance("org.xwiki.rest.model.jaxb");
107 Unmarshaller unmarshaller = context.createUnmarshaller();
108
109 GetMethod getMethod = new GetMethod("http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome");
110 getMethod.addRequestHeader("Accept", "application/xml");
111 httpClient.executeMethod(getMethod);
112
113 Page page = (Page) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
114 {{/code}}
115
116 And you will have all the information about the Main.WebHome page in the Page object, without the need of handling XML directly.
117
118 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.
119
120 By using curl, the previous example would have been:
121
122 {{code language="xml"}}
123 $ curl http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome
124
125 <page xmlns="http://www.xwiki.org">
126 <link rel="http://www.xwiki.org/rel/space" href="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main"/>
127 ...
128 {{/code}}
129
130 == Authentication ==
131
132 The XWiki RESTful API supports several types of authentication:
133
134 * **HTTP BASIC Auth**: You provide your credentials using the Authorization HTTP header
135 * **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.
136 * **Custom authentication methods:** if you have setup a custom authenticator on your wiki (such as [[OIDC>>extensions:Extension.OpenID Connect.WebHome]], or [[Trusted authentication>>extensions:Extension.Trusted authentication framework]] or even your own custom ones), additional authentication methods may be available for the RESTful API, provided by these authenticators.
137
138 If you don't provide any credentials the XWiki RESTful API will recognize you as a XWiki.Guest user.
139
140 So if you have, let's say a Main.PrivatePage, and you try to do:
141
142 {{code language="none"}}
143 $ curl -v http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/PrivatePage
144 ...
145 < HTTP/1.1 401 Unauthorized
146 ...
147 {{/code}}
148
149 You will get an Unauthorized empty response.
150
151 On the contrary, by specifying Admin credentials you gain access to the actual page:
152
153 {{code language="xml"}}
154 $ curl -u Admin:admin http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/PrivatePage
155
156 <page xmlns="http://www.xwiki.org">
157 <link rel="http://www.xwiki.org/rel/space" href="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main"/>
158 ...
159 <content>Only admin can see this</content>
160 </page>
161 {{/code}}
162
163 === CSRF Token ===
164
165 {{version since="14.10.8,15.2"}}
166 When using a ##POST## request with a content type of ##text/plain##, ##multipart/form-data## or ##application/www-form-urlencoded##, a form token needs to be sent in the header ##XWiki-Form-Token## to prevent cross-site request forgery. The form token is provided in every response in the same header so a ##GET## request to any supported endpoint can be used to obtain a form token. If the form token is missing or wrong, a response with status code 403 and "Invalid or missing form token." as body of type ##text/plain## is sent. As of XWiki 15.2, the form token will stay the same for a user until the server is restarted. As server restarts might happen at any time, API clients should handle this response code and re-try the request with the form token that is returned in the error response. When the form token is provided in a request where it isn't necessary, it won't be checked for validity so it doesn't hurt to just send the token in every request.
167
168 It cannot be excluded that in the future, the form token might depend on the user's session. Therefore, for compatibility with future versions, it might be a good idea to store and send cookies.
169
170 When using the REST API in JavaScript code from within XWiki's UI, the form token is automatically sent in every same-origin request initiated through ##fetch## or ##XMLHttpRequest##. Therefore, no special steps should be needed for REST requests to the current XWiki instance.
171 {{/version}}
172
173 == Sending representations ==
174
175 Many resources are modifiable, so you can send representations in order to change the state of those resources (e.g., pages).
176 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).
177
178 Resource update is usually done by using the PUT method, while resource creation is done via PUT or POST.
179
180 For example, in order to create a page you might do the following:
181
182 {{code language="xml"}}
183 $ 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
184
185 <page xmlns="http://www.xwiki.org">
186 <link rel="http://www.xwiki.org/rel/space" href="http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main"/>
187 ...
188 <version>1.1</version>
189 <majorVersion>1</majorVersion>
190 <minorVersion>1</minorVersion>
191 <created>2009-03-21+01:00</created>
192 <creator>XWiki.Admin</creator>
193 <modified>2009-03-21+01:00</modified>
194 <modifier>XWiki.Admin</modifier>
195 <content>This is a new page</content>
196 </page>
197 {{/code}}
198
199 Where newpage.xml is an XML file containing
200
201 {{code language="xml"}}
202
203 <page xmlns="http://www.xwiki.org">
204 <title>Hello world</title>
205 <syntax>xwiki/2.0</syntax>
206 <content>This is a new page</content>
207 </page>
208 {{/code}}
209
210 The page has been created and is accessible. Subsequent PUT requests to the page URI will modify its content.
211
212 You can specify a subset of the three elements {{{title}}}, {{{syntax}}}, and {{{content}}} in the XML when updating/creating a page.
213 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.
214
215 == Overcoming browser limitations ==
216
217 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.
218
219 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.
220
221 This overriding mechanism allows the interaction with the XWiki RESTful API by using any kind of browser.
222
223 == PUT vs POST ==
224
225 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.
226
227 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.
228
229 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.
230
231 == Headers ==
232
233 The response of the REST requests always contain some custom headers that might be useful:
234
235 * ##xwiki-version##: contains the representation of the version of XWiki defined in ##version.properties## (e.g. 14.4.6)
236 * ##xwiki-user##: contains the reference of the user used to perform the request (e.g. xwiki:XWiki.JohnDoe). If the request is performed as guest, the header won't be present.
237
238 = XWiki RESTful API Documentation =
239
240 In this section you will find the documentation of the whole XWiki RESTful API.
241
242 **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]].
243
244 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.
245
246 == Root resources ==
247
248 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)
249
250 === / ===
251
252 * **HTTP Method:** GET
253 ** **Media types:**
254 *** application/xml (XWiki element)
255 ** **Description:** Retrieves the entry root description containing information about the server (currently returns the XWiki product Version).
256 ** **Status codes:**
257 *** 200: If the request was successful.
258
259 === /syntaxes ===
260
261 * **HTTP Method:** GET
262 ** **Media types:**
263 *** application/xml (Syntaxes element)
264 ** **Description:** The list of syntaxes supported by the XWiki instance.
265 ** **Status codes:**
266 *** 200: If the request was successful.
267
268 === /wikis ===
269
270 * **HTTP Method:** GET
271 ** **Media types:**
272 *** application/xml (Wikis element)
273 ** **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'.
274 ** **Status codes:**
275 *** 200: If the request was successful.
276
277 === /wikis/query?q~={query}&wikis~=wikiList[&distinct~={true,false}][&order~={asc,desc}][&start~=n][&number~=n][&prettyNames~={true,false}] ===
278
279 * **HTTP Method:** GET
280 ** **Media types:**
281 *** application/xml (SearchResults element)
282 ** **Description:** Search resources (pages and attachments):
283 *** [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.
284 *** [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.
285 ** **Status codes:**
286 *** 200: If the request was successful.
287
288 === /wikis/{wikiName} ===
289
290 * **HTTP Method:** GET
291 ** **Media types:**
292 *** application/xml (Wiki element)
293 ** **Description:** information about the wiki
294 ** **Status codes:**
295 *** 200: If the request was successful.
296
297 * **HTTP Method:** POST
298 ** **Accepted Media types:**
299 *** octet/stream (A XAR file)
300 ** **Media types:**
301 *** application/xml (Wiki element)
302 ** **Query parameters**
303 *** backup={true/false} - import XAR as a backup XAR
304 *** history={RESET/REPLACE/ADD} - history importing
305 ** **Description:** import a XAR in a wiki.
306 ** **Status codes:**
307 *** 200: If the request was successful.
308
309 === /wikis/{wikiName}/children?[offset~=0][&limit~=-1][&search~=] ===
310
311 {{version since="16.4.0RC1"}}
312 * **HTTP Method:** GET
313 ** **Media types:**
314 *** application/xml (Pages element)
315 ** **Query parameters**
316 *** offset={integer} the index of the first child page to return, defaults to 0
317 *** limit={integer} the maximum number of child pages to return, defaults to -1 which means no limit
318 *** search={string} a search string to filter the child pages by name or title, defaults to empty string which means no filtering
319 ** **Description:** the top level pages in the specified wiki
320 ** **Status codes:**
321 *** 200: If the request was successful.
322 {{/version}}
323
324 === /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}] ===
325
326 * **HTTP Method:** GET
327 ** **Media types:**
328 *** application/xml (SearchResults element)
329 ** **Description:** Returns 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} and are obtained via a HQL query. The specified keywords are converted to uppercase and used in a HQL LIKE clause (e.g if the scope is ##CONTENT## then the document's content is matched to the specified keywords).
330 ** **Status codes:**
331 *** 200: If the request was successful.
332
333 === /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] ===
334
335 * **HTTP Method:** GET
336 ** **Media types:**
337 *** application/xml (SearchResults element)
338 ** **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>>Documentation.DevGuide.Scripting.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 type is //hql// or //xwql// and //className// is specified, the result will also contain the data for the first object of the corresponding class.
339 ** **Status codes:**
340 *** 200: If the request was successful.
341
342 === /wikimanager (This resource is only available when using the [[multi-wiki>>extensions:Extension.Wiki Application]] feature) ===
343
344 * **HTTP Method:** POST
345 ** **Accepted Media types:**
346 *** application/xml (Wiki element)
347 ** **Media types:**
348 *** application/xml (Wiki element)
349 ** **Query parameters**
350 *** template - the wiki template to be used for initializing the wiki.
351 *** history={RESET/REPLACE/ADD} - history importing
352 ** **Description:** create a new wiki.
353 ** **Status codes:**
354 *** 200: If the request was successful.
355
356 == Space resources ==
357
358 === /wikis/{wikiName}/spaces[?start~=offset&number~=n] ===
359
360 * **HTTP Method:** GET
361 ** **Media types:**
362 *** application/xml (Spaces element)
363 ** **Description:** Retrieves the list of spaces available in the {wikiName} wiki.
364 ** **Status codes:**
365 *** 200: If the request was successful.
366
367 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/search?q~={keywords}~[~[&scope~={name,content,title,objects}...]&number~=n] ===
368
369 * **HTTP Method:** GET
370 ** **Media types:**
371 *** application/xml (Search results element)
372 ** **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}
373 ** **Status codes:**
374 *** 200: If the request was successful.
375 *** 401: If the user is not authorized.
376
377 == Page resources ==
378
379 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages[?start~=offset&number~=n] ===
380
381 * **HTTP Method:** GET
382 ** **Media types:**
383 *** application/xml (Pages element)
384 ** **Description:** The list of pages in the space {spaceName}
385 ** **Status codes:**
386 *** 200: If the request was successful.
387 *** 401: If the user is not authorized.
388
389 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}[?prettyNames~={true,false}&objects~={true,false}&class~={true,false}&attachments~={true,false}&minorRevision~={true,false}] ===
390
391 * **HTTP Method:** GET
392 ** **Media types:**
393 *** application/xml (Page element)
394 ** **Query parameters**
395 *** ##prettyNames##: also return the pretty name for various document information (like the author display name, etc). Disabled by default.
396 *** ##objects##: //[since 7.3M1]// also return the objects. Disabled by default.
397 *** ##class##: //[since 7.3M1]// also return the class. Disabled by default.
398 *** ##attachments##: //[since 7.3M1]// also return the attachments metadatas. Disabled by default.
399 ** **Description:**
400 ** **Status codes:**
401 *** 200: If the request was successful.
402 *** 401: If the user is not authorized.
403
404 * **HTTP Method:** PUT
405 ** **Accepted Media types:**
406 *** application/xml (Page element)
407 *** text/plain (Only page content)
408 *** application/x-www-form-urlencoded (allowed field names: title, parent, hidden //[since 7.3]//, content)
409 ** **Media types:**
410 *** application/xml (Page element)
411 ** **Query parameters**
412 *** ##minorRevision## ({{info}}Since 9.11.4 & 10.2RC1{{/info}}): Create a minor revision for the page. Disabled by default.
413 ** **Description:** Create or updates a page.
414 ** **Status codes:**
415 *** 201: If the page was created.
416 *** 202: If the page was updated.
417 *** 304: If the page was not modified.
418 *** 401: If the user is not authorized.
419
420 * **HTTP Method:** DELETE
421 ** **Media types:**
422 *** application/xml (Page element)
423 ** **Description:** Delete the page.
424 ** **Status codes:**
425 *** 204: If the request was successful.
426 *** 401: If the user is not authorized.
427
428 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/history[?start~=offset&number~=n] ===
429
430 * **HTTP Method:** GET
431 ** **Media types:**
432 *** application/xml (History element)
433 ** **Description:** The list of all the versions of the given page.
434 ** **Status codes:**
435 *** 200: If the request was successful.
436 *** 401: If the user is not authorized.
437
438 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/history/{version} ===
439
440 * **HTTP Method:** GET
441 ** **Media types:**
442 *** application/xml (Page element)
443 ** **Description:** The page at version {version}
444 ** **Status codes:**
445 *** 200: If the request was successful.
446 *** 401: If the user is not authorized.
447
448 ==== /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/translations[?start~=offset&number~=n] ====
449
450 * **HTTP Method:** GET
451 ** **Media types:**
452 *** application/xml (Translations element)
453 ** **Description:** The list of available translation for the page
454 ** **Status codes:**
455 *** 200: If the request was successful.
456 *** 401: If the user is not authorized.
457
458 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/translations/{language}[?minorRevision~={true,false}] ===
459
460 * **HTTP Method:** GET
461 ** **Media types:**
462 *** application/xml (Page element)
463 ** **Description:** The page at in the given {language}.
464 ** **Status codes:**
465 *** 200: If the request was successful.
466 *** 401: If the user is not authorized.
467
468 * **HTTP Method:** PUT
469 ** **Accepted Media types:**
470 *** application/xml (Page element)
471 *** text/plain (Only page content)
472 *** application/x-www-form-urlencoded (allowed field names: title, parent, content)
473 ** **Media types:**
474 *** application/xml (Page element)
475 ** **Query parameters**
476 *** ##minorRevision## ({{info}}Since 9.11.4 & 10.2RC1{{/info}}): Create a minor revision for the page. Disabled by default.
477 ** **Description:** Create or updates a page translation.
478 ** **Status codes:**
479 *** 201: If the page was created.
480 *** 202: If the page was updated.
481 *** 304: If the page was not modified.
482 *** 401: If the user is not authorized.
483
484 * **HTTP Method:** DELETE
485 ** **Media types:**
486 *** application/xml (Page element)
487 ** **Description:** Delete the page translation.
488 ** **Status codes:**
489 *** 204: If the request was successful.
490 *** 401: If the user is not authorized.
491
492 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/translations/{language}/history ===
493
494 * **HTTP Method:** GET
495 ** **Media types:**
496 *** application/xml (History element)
497 ** **Description:** The list of all the available revisions of the page in a given {language}.
498 ** **Status codes:**
499 *** 200: If the request was successful.
500 *** 401: If the user is not authorized.
501
502 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/translations/{lang}/history/{version} ===
503
504 * **HTTP Method:** GET
505 ** **Media types:**
506 *** application/xml (Page element)
507 ** **Description:** A page at a given {version} in a given {language}.
508 ** **Status codes:**
509 *** 200: If the request was successful.
510 *** 401: If the user is not authorized.
511
512 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/children?[start~=0][&number~=-1][&prettyNames~={false,true}][&hierarchy~={parentchild,nestedpages}][&search~=] ===
513
514 * **HTTP Method:** GET
515 ** **Media types:**
516 *** application/xml (Pages element)
517 ** **Query parameters**
518 *** start={integer} the index of the first child page to return, defaults to 0
519 *** number={integer} the maximum number of child pages to return, defaults to -1 which means no limit
520 *** prettyNames={boolean} whether to include rendered page titles in the response (can slow down the response), defaults to false
521 *** {{version since="16.4.0RC1"}}hierarchy={parentchild,nestedpages} the type of hierarchy to use when searching for child pages; for backwards compatibility, the default hierarchy used is "parentchild"; use "nestedpages" hierarchy if you want results that match the current XWiki UI{{/version}}
522 *** {{version since="16.4.0RC1"}}search={string} a search string to filter the child pages by name or title, defaults to empty string which means no filtering{{/version}}
523 ** **Description:** The list of the children of a given page.
524 ** **Status codes:**
525 *** 200: If the request was successful.
526 *** 401: If the user is not authorized.
527
528 === /wikis/{wikiName}/pages[?name~=paneName&space~=spaceName&author~=authorName] ===
529
530 * **HTTP Method:** GET
531 ** **Media types:**
532 *** application/xml (Pages element)
533 ** **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.
534 ** **Status codes:**
535 *** 200: If the request was successful.
536 *** 401: If the user is not authorized.
537
538 == Tag resources ==
539
540 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/tags[?minorRevision~={true,false}] ===
541
542 * **HTTP Method:** GET
543 ** **Media types:**
544 *** application/xml (Tags element)
545 ** **Description:** List page tags.
546 ** **Status codes:**
547 *** 200: If the request was successful.
548 *** 401: If the user is not authorized.
549
550 * **HTTP Method:** PUT
551 ** **Accepted Media types:**
552 *** application/xml (Tag element)
553 *** text/plain
554 *** application/x-www-form-urlencoded (allowed field names: tag)
555 ** **Media types:**
556 *** application/xml (Tags element)
557 ** **Query parameters**
558 *** ##minorRevision## ({{info}}Since 9.11.4 & 10.2RC1{{/info}}): Create a minor revision for the page. Disabled by default.
559 ** **Description:** Add a tag to the page.
560 ** **Status codes:**
561 *** 202: If the request was successful.
562 *** 401: If the user is not authorized.
563
564 === /wikis/{wikiName}/tags ===
565
566 * **HTTP Method:** GET
567 ** **Media types:**
568 *** application/xml (Tags element)
569 ** **Description:** The list of all available tags
570 ** **Status codes:**
571 *** 200: If the request was successful.
572 *** 401: If the user is not authorized.
573
574 === /wikis/{wikiName}/tags/{tag1}[,{tag2},{tag3}...][?start~=offset&number~=n] ===
575
576 * **HTTP Method:** GET
577 ** **Media types:**
578 *** application/xml (Pages element)
579 ** **Description:** The list of pages having the specified tags.
580 ** **Status codes:**
581 *** 200: If the request was successful.
582 *** 401: If the user is not authorized.
583
584 == Comments resources ==
585
586 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/comments[?start~=offset&number~=n] ===
587
588 * **HTTP Method:** GET
589 ** **Media types:**
590 *** application/xml (Comments element)
591 ** **Description:** The list of comments on a given page.
592 ** **Status codes:**
593 *** 200: If the request was successful.
594 *** 401: If the user is not authorized.
595
596 * **HTTP Method:** POST
597 ** **Accepted Media types:**
598 *** application/xml (Comment element)
599 *** text/plain
600 *** application/x-www-form-urlencoded - allowed field names: ##text##, ##replyTo## (object number of the replied comment, since XE 2.3)
601 ** **Media types:**
602 *** application/xml (Comment element)
603 ** **Description:** Create a comment on the given page.
604 ** **Status codes:**
605 *** 201: If the comment was created. (The Location header will contain the URI where the comment has been created.)
606 *** 401: If the user is not authorized.
607
608 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/comments/{commentId} ===
609
610 * **HTTP Method:** GET
611 ** **Media types:**
612 *** application/xml (Comment element)
613 ** **Description:** A specific comment on a page
614 ** **Status codes:**
615 *** 200: If the request was successful.
616 *** 401: If the user is not authorized.
617
618 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/history/{version}/comments ===
619
620 * **HTTP Method:** GET
621 ** **Media types:**
622 *** application/xml (Comments element)
623 ** **Description:** The list of comments at a specific page {version}.
624 ** **Status codes:**
625 *** 200: If the request was successful.
626 *** 401: If the user is not authorized.
627
628 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/history/{version}/comments/{commentId} ===
629
630 * **HTTP Method:** GET
631 ** **Media types:**
632 *** application/xml (Comment element)
633 ** **Description:** A comment at a specific page {version}.
634 ** **Status codes:**
635 *** 200: If the request was successful.
636 *** 401: If the user is not authorized.
637
638 == Attachments resources ==
639
640 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/attachments[?start~=offset&number~=n] ===
641
642 * **HTTP Method:** GET
643 ** **Media types:**
644 *** application/xml (Attachments element)
645 ** **Description:** The list of attachments of a given page.
646 ** **Status codes:**
647 *** 200: If the request was successful.
648 *** 401: If the user is not authorized.
649
650 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/attachments/{attachmentName} ===
651
652 * **HTTP Method:** GET
653 ** **Media types:**
654 *** The same of the attachment media type.
655 ** **Description:** The attachment identified by {attachmentName} on a given page.
656 ** **Status codes:**
657 *** 200: If the request was successful.
658 *** 401: If the user is not authorized.
659
660 * **HTTP Method:** PUT
661 ** **Accepted media types:**
662 *** **/**
663 ** **Media types:**
664 *** application/xml (AttachmentSummary element)
665 ** **Description:** Create an attachment identified by {attachmentName} on a given page.
666 ** **Status codes:**
667 *** 201: If the attachment was created.
668 *** 202: If the attachment was updated.
669 *** 401: If the user is not authorized.
670
671 * **HTTP Method:** DELETE
672 ** **Media types:**
673 ** **Description:** Delete the attachment identified by {attachmentName} on a given page.
674 ** **Status codes:**
675 *** 204: If the attachment was deleted.
676 *** 401: If the user is not authorized.
677
678 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/history/{version}/attachments[?start~=offset&number~=n] ===
679
680 * **HTTP Method:** GET
681 ** **Media types:**
682 *** application/xml (Attachments element)
683 ** **Description:** The list of attachments at a given page {version}.
684 ** **Status codes:**
685 *** 200: If the request was successful.
686 *** 401: If the user is not authorized.
687
688 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/history/{version}/attachments/{attachmentName} ===
689
690 * **HTTP Method:** GET
691 ** **Media types:**
692 *** The same of the attachment media type.
693 ** **Description:** The attachment identified by {attachmentName} on a given page {version}.
694 ** **Status codes:**
695 *** 200: If the request was successful.
696 *** 401: If the user is not authorized.
697
698 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/attachments/{attachmentName}/history ===
699
700 * **HTTP Method:** GET
701 ** **Media types:**
702 *** application/xml (Attachments element)
703 ** **Description:** The list of available version for the {attachmentName}
704 ** **Status codes:**
705 *** 200: If the request was successful.
706 *** 401: If the user is not authorized.
707
708 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/attachments/{attachmentName}/history/{version} ===
709
710 * **HTTP Method:** GET
711 ** **Media types:**
712 *** The same of the attachment media type.
713 ** **Description:** The {attachmentName} at a given {version}
714 ** **Status codes:**
715 *** 200: If the request was successful.
716 *** 401: If the user is not authorized.
717
718 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/attachments[?name~=attachmentName&page~=pageName&author~=authorName&types~=attachmentTypeList&start~=offset&number~=n] ===
719
720 * **HTTP Method:** GET
721 ** **Media types:**
722 *** application/xml (Attachments element)
723 ** **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.
724 ** **Status codes:**
725 *** 200: If the request was successful.
726 *** 401: If the user is not authorized.
727
728 === /wikis/{wikiName}/attachments[?name~=attachmentName&page~=pageName&space~=spaceName&author~=authorName&types~=attachmentTypeList&start~=offset&number~=n] ===
729
730 * **HTTP Method:** GET
731 ** **Media types:**
732 *** application/xml (Attachments element)
733 ** **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.
734 ** **Status codes:**
735 *** 200: If the request was successful.
736 *** 401: If the user is not authorized.
737
738 == Object resources ==
739
740 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/objects[?start~=offset&number~=n] ===
741
742 * **HTTP Method:** GET
743 ** **Media types:**
744 *** application/xml (Objects element)
745 ** **Description:** The list of objects associated to a page.
746 ** **Status codes:**
747 *** 200: If the request was successful.
748 *** 401: If the user is not authorized.
749
750 * **HTTP Method:** POST
751 ** **Accepted media types:**
752 *** application/xml (Object element)
753 *** application/x-www-form-urlencoded (a set of property#name=value pairs representing properties and a field className)
754 **** e.g. {{code language="none"}}className=XWiki.XWikiUsers&property#first_name=John&property#last_name=Doe{{/code}}
755 ** **Media types:**
756 *** application/xml (Object element)
757 ** **Description:** Create a new object.
758 ** **Status codes:**
759 *** 201: If the object was created (The Location header will contain the URI associated to the newly created object).
760 *** 401: If the user is not authorized.
761
762 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/objects/{className}[?start~=offset&number~=n] ===
763
764 * **HTTP Method:** GET
765 ** **Media types:**
766 *** application/xml (Objects element)
767 ** **Description:** The list of objects of a given {className} associated to a page.
768 ** **Status codes:**
769 *** 200: If the request was successful.
770 *** 401: If the user is not authorized.
771
772 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/objects/{className}/{objectNumber}[?minorRevision~={true,false}] ===
773
774 * **HTTP Method:** GET
775 ** **Media types:**
776 *** application/xml (Object element)
777 ** **Description:** The object of type {className} identified by {objectNumber} associated to the given page.
778 ** **Status codes:**
779 *** 200: If the request was successful.
780 *** 401: If the user is not authorized.
781
782 * **HTTP Method:** PUT
783 ** **Accepted media types:**
784 *** application/xml (Object element)
785 *** application/x-www-form-urlencoded (a set of property#name=value pairs representing properties)
786 ** **Media types:**
787 *** application/xml (Object element)
788 ** **Query parameters**
789 *** ##minorRevision## ({{info}}Since 9.11.4 & 10.2RC1{{/info}}): Create a minor revision for the page. Disabled by default.
790 ** **Description:** Modify the object properties.
791 ** **Status codes:**
792 *** 202: If the object was updated.
793 *** 401: If the user is not authorized.
794
795 * **HTTP Method:** DELETE
796 ** **Media types:**
797 ** **Description:** Delete the object.
798 ** **Status codes:**
799 *** 204: If the object was deleted.
800 *** 401: If the user is not authorized.
801
802 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/objects/{className}/{objectNumber}/properties ===
803
804 * **HTTP Method:** GET
805 ** **Media types:**
806 *** application/xml (Properties element)
807 ** **Description:** The properties of the object of type {className} identified by {objectNumber} associated to the given page.
808 ** **Status codes:**
809 *** 200: If the request was successful.
810 *** 401: If the user is not authorized.
811
812 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/objects/{className}/{objectNumber}/properties/{propertyName}[?minorRevision~={true,false}] ===
813
814 * **HTTP Method:** GET
815 ** **Media types:**
816 *** application/xml (Properties element)
817 ** **Description:** The property {propertyname} of the object of type {className} identified by {objectNumber} associated to the given page.
818 ** **Status codes:**
819 *** 200: If the request was successful.
820 *** 401: If the user is not authorized.
821
822 * **HTTP Method:** PUT
823 ** **Accepted media types:**
824 *** application/xml (Property element)
825 *** text/plain
826 *** application/x-www-form-urlencoded (a field property#name=value pairs representing a property)
827 ** **Media types:**
828 *** application/xml (Property element)
829 ** **Query parameters**
830 *** ##minorRevision## ({{info}}Since 9.11.4 & 10.2RC1{{/info}}): Create a minor revision for the page. Disabled by default.
831 ** **Description:** Modify the object properties.
832 ** **Status codes:**
833 *** 202: If the object was updated.
834 *** 401: If the user is not authorized.
835
836 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/history/{version}/objects[?start~=offset&number~=n] ===
837
838 * **HTTP Method:** GET
839 ** **Media types:**
840 *** application/xml (Objects element)
841 ** **Description:** The list of objects associated to a page at a given {version}.
842 ** **Status codes:**
843 *** 200: If the request was successful.
844 *** 401: If the user is not authorized.
845
846 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/history/{version}/objects/{className}/{objectNumber} ===
847
848 * **HTTP Method:** GET
849 ** **Media types:**
850 *** application/xml (Object element)
851 ** **Description:** The object of type {className} identified by {objectNumber} associated to the given page at a given {version}.
852 ** **Status codes:**
853 *** 200: If the request was successful.
854 *** 401: If the user is not authorized.
855
856 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/history/{version}/objects/{className}/{objectNumber}/properties ===
857
858 * **HTTP Method:** GET
859 ** **Media types:**
860 *** application/xml (Properties element)
861 ** **Description:** The properties of the object of type {className} identified by {objectNumber} associated to the given page at a given {version}.
862 ** **Status codes:**
863 *** 200: If the request was successful.
864 *** 401: If the user is not authorized.
865
866 === /wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}/history/{version}/objects/{className}/{objectNumber}/properties/{propertyName} ===
867
868 * **HTTP Method:** GET
869 ** **Media types:**
870 *** application/xml (Properties element)
871 ** **Description:** The property {propertyName} of the object of type {className} identified by {objectNumber} associated to the given page at a given {version}.
872 ** **Status codes:**
873 *** 200: If the request was successful.
874 *** 401: If the user is not authorized.
875
876 === /wikis/{wikiName}/classes/{className}/objects[?start~=offset&number~=n] ===
877
878 * **HTTP Method:** GET
879 ** **Media types:**
880 *** application/xml (Objects element)
881 ** **Description:** The list of all the objects of a given {className}.
882 ** **Status codes:**
883 *** 200: If the request was successful.
884 *** 401: If the user is not authorized.
885
886 == Class resources ==
887
888 === /wikis/{wikiName}/classes[?start~=offset&number~=n] ===
889
890 * **HTTP Method:** GET
891 ** **Media types:**
892 *** application/xml (Classes element)
893 ** **Description:** The list of all the classes defined in the wiki {wikiName}
894 ** **Status codes:**
895 *** 200: If the request was successful.
896 *** 401: If the user is not authorized.
897
898 === /wikis/{wikiName}/classes/{className} ===
899
900 * **HTTP Method:** GET
901 ** **Media types:**
902 *** application/xml (Class element)
903 ** **Description:** The {className} definition
904 ** **Status codes:**
905 *** 200: If the request was successful.
906 *** 401: If the user is not authorized.
907
908 === /wikis/{wikiName}/classes/{className}/properties ===
909
910 * **HTTP Method:** GET
911 ** **Media types:**
912 *** application/xml (Properties element)
913 ** **Description:** The properties of the class {className}.
914 ** **Status codes:**
915 *** 200: If the request was successful.
916 *** 401: If the user is not authorized.
917
918 === /wikis/{wikiName}/classes/{className}/properties/{propertyName} ===
919
920 * **HTTP Method:** GET
921 ** **Media types:**
922 *** application/xml (Property element)
923 ** **Description:** The property {propertyName} of the class {className}.
924 ** **Status codes:**
925 *** 200: If the request was successful.
926 *** 401: If the user is not authorized.
927
928 === /wikis/{wikiName}/classes/{className}/properties/{propertyName}/values {{info}}Since 9.8RC1{{/info}} ===
929
930 Request parameters:
931
932 |=Name|=Description|
933 |limit|Limit the number of values returned. Zero or a negative number means no limit.
934 |fp|Filter parameters, used to filter the returned values. You can pass multiple filter values by repeating the query string parameter. The way in which the property values are filtered depends on the property type.
935
936 * **HTTP Method:** GET
937 ** **Media types:**
938 *** application/xml (Property element)
939 ** **Description:** The list of values for the property {propertyName} of the class {className}. At the moment only Database List properties are supported.
940 ** **Status codes:**
941 *** 200: If the request was successful.
942 *** 401: If the user is not authorized to view the specified property.
943 *** 404: If the specified property doesn't exist.
944
945 == Job resources ==
946
947 A job is identified by an ID (##jobId##) which is a list of strings. In the REST URL, you have to represent the ID with a list of strings separated by ##/##. (eg: ##refactoring/delete/11451##).
948
949 === /jobstatus/{jobId} {{info}}Since 7.2M3{{/info}} ===
950
951 Request parameters:
952
953 |=Name|=Required|=Values|=Default|=Description|=Version
954 |##request##|no|##true~|false##|##false##|Return also the job request|9.1RC1
955 |##progress##|no|##true~|false##|##true##|Return also the job progress|9.1RC1
956 |##log##|no|##true~|false##|##false##|Return also the job log|9.1RC1
957 |##log_fromLevel##|no|##error~|warn~|info~|debug~|trace##| |Indicate the level from which to return logs|9.1RC1
958
959 * **HTTP Method:** GET
960 ** **Media types:**
961 *** application/xml (JobStatus element)
962 ** **Description:** status of a job
963 ** **Status codes:**
964 *** 200: If the request was successful.
965 *** 404: If the job status has not been found
966
967 === /joblog/{jobId} {{info}}Since 7.2M3{{/info}} ===
968
969 Request parameters:
970
971 |=Name|=Required|=Values|=Default|=Description|=Version
972 |##level##|no|##error~|warn~|info~|debug~|trace##| |Indicate the exact level for which to return logs|7.2M3
973 |##fromLevel##|no|##error~|warn~|info~|debug~|trace##| |Indicate the level from which to return logs|7.2M3
974
975 * **HTTP Method:** GET
976 ** **Media types:**
977 *** application/xml (JobLog element)
978 ** **Description:** log of a job
979 ** **Status codes:**
980 *** 200: If the request was successful.
981 *** 404: If the job status has not been found
982
983 === /jobs {{info}}Since 9.1RC1{{/info}} ===
984
985 Request parameters:
986
987 |=Name|=Required|=Values|=Default|=Description|=Version
988 |##jobType##|yes| | |The type of the job to pass to the Job Executor|9.1RC1
989 |##async##|no|##true~|false##|##true##|If false, return the response only when the job is done|9.1RC1
990
991 This API is designed to be a REST clone of the JobExecutor Java API (the only real difference right now being way to deal with asynchronous jobs) documented on http://extensions.xwiki.org/xwiki/bin/view/Extension/Job+Module#HUseanexistingjob so the concepts (job type, job request) are the same and the exact information to put in the job request depends on the job you want to run and are usually documented in the extension this job is coming from (extension module, refactoring, etc.).
992
993 * **HTTP Method:** PUT
994 ** **Input:**
995 *** Media Types: ##application/xml## or ##application/json##
996 *** Input body: ##JobRequest## element
997 ** **Output:**
998 *** Media Types: ##application/xml## or ##application/json##
999 *** Response body: ##JobStatus## element
1000 ** **Description:** Start a new job synchronously or asynchronously
1001 ** **Status codes:**
1002 *** 200: If the job was successfully executed
1003 *** 401: If the user is not authorized (i.e. doesn't have Programming Rights)
1004 *** 500: Failing jobs with ##async=false## return an error 500 (Since 9.7RC1)
1005
1006 Jobs started through the REST API automatically get their runtime context injected with the following REST HTTP request context properties:
1007
1008 * current wiki
1009 * current user
1010 * request URL and parameters
1011
1012 There is JAXB objects provided to make easy to create a request for Java and other JVM based clients. For other use cases the hard part is generally generating the XML to send as content and you can either:
1013
1014 * ask for the status of an existing job to have an hint of how the XML/JSON should look like (see [[jobstatus section>>#H2Fjobstatus2F7BjobId7D]])
1015 * generate this XML in a script in a wiki page, you can look at the following example to help with that: https://snippets.xwiki.org/xwiki/bin/view/Extension/Generate%20Refactoring%20Job%20REST%20request%20XML/
1016
1017 === Example of Extension Manager installJob ===
1018
1019 Using the attach:installjobrequest.xml file you can use a request like the following one to ask for the installation of an extension (in this example the XWiki OIDC module version 1.28):
1020
1021 {{code language="none"}}
1022 curl -i --user "Admin:admin" -X PUT -H "Content-Type: text/xml" "http://localhost:8080/xwiki/rest/jobs?jobType=install&async=false" --upload-file installjobrequest.xml
1023 {{/code}}
1024
1025 == Localization resources ==
1026
1027 For more details see the [[Localization Module documentation>>extensions:Extension.Localization.WebHome]].
1028
1029 {{version since="13.3RC1"}}
1030 === /wikis/{wikiName}/localization/translations[?locale~=l&prefix~=p[&key~=k]*] ===
1031
1032 * **HTTP Method**: GET
1033 ** **Media Types:** ##application/xml## or ##application/json##
1034 ** **Description: **The list of translations of the requested keys in a given locale
1035 ** **Query Parameters:**
1036 *** **locale:** (optional) the locale of the returned translation, if missing the locale is resolved from the context
1037 *** **prefix:** (optional) a common prefix concatenated to all the provided keys.
1038 *** **key:** (multiple) a list of translation keys
1039 ** **Status Code:**
1040 *** 200: if the request was successful
1041 ** **Response:**
1042 *** a list of translation objects, each containing the translation key (concatenated with the prefix) and the resolved raw sources (the translation values without the parameters resolved).
1043 {{/version}}
1044
1045 == Icon Theme resources ==
1046
1047 For more details see the [[Icon Theme Application>>extensions:Extension.Icon Theme Application.WebHome]].
1048
1049 {{version since="13.3RC1"}}
1050 === /wikis/{wikiName}/iconThemes/icons[?[name~=n]*] ===
1051
1052 * **HTTP Method**: GET
1053 ** **Media Types:** ##application/xml## or ##application/json##
1054 ** **Description: **Provides the metadata of the icons of the current icon theme in a given ##{wikiName}## wiki
1055 ** **Query Parameters:**
1056 *** **name:** (multiple) the name of the requested icons
1057 ** **Status Code:**
1058 *** 200: if the request was successful
1059 ** **Response:**
1060 *** An object with two attributes: ##icon## is a list of the requested icons metadata, and ##missingIcons## an array of names of requested icons that couldn't be found in the current theme.
1061
1062 === /wikis/{wikiName}/iconThemes/{iconTheme}/icons[?[name~=n]*] ===
1063
1064 * **HTTP Method**: GET
1065 ** **Media Types:** ##application/xml## or ##application/json##
1066 ** **Description: **Provides the metadata of the icons of the ##{iconTheme}## icon theme in a given ##{wikiName}## wiki
1067 ** **Query Parameters:**
1068 *** **name:** (multiple) the name of the requested icons
1069 ** **Status Code:**
1070 *** 200: if the request was successful
1071 ** **Response:**
1072 *** An object with two attributes: ##icon## is a list of the requested icons metadata, and ##missingIcons## an array of names of requested icons that couldn't be found in the requested theme.
1073 {{/version}}
1074
1075 == Other resources ==
1076
1077 === /wikis/{wikiName}/modifications[?start~=offset&number~=n&date~=t] ===
1078
1079 * **HTTP Method:** GET
1080 ** **Media types:**
1081 *** application/xml (Modifications element)
1082 ** **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)
1083 ** **Status codes:**
1084 *** 200: If the request was successful.
1085 *** 401: If the user is not authorized.
1086
1087 = Custom resources =
1088
1089 == In Wiki Pages ==
1090
1091 If you can't find an existing REST endpoint for your needs, you can create your own own by creating a wiki page and putting script in it. For example let's imagine you'd like to get a list of all pages under a given space. You could write a page, say ##GetChildren## with the following content:
1092
1093 {{code language="velocity"}}
1094 {{velocity}}
1095 #if ("$!request.space" != '')
1096 #set ($discard = $response.setContentType('text/xml'))
1097
1098 <pages>
1099 #set ($query = $services.query.xwql("select doc.fullName from Document doc where ((doc.space like :spacelike escape '!') or (doc.space = :space)) and language='' order by doc.date desc"))
1100 #set ($spaceReferenceString = $request.space)
1101 #set ($spaceLike = $spaceReferenceString.replaceAll('([%_!])', '!$1').concat('.%'))
1102 #set ($query = $query.bindValue('spacelike', $spaceLike))
1103 #set ($query = $query.bindValue('space', $spaceReferenceString))
1104 #foreach ($item in $query.execute())
1105 <page>$item</page>
1106 #end
1107 </pages>
1108 #end
1109 {{/velocity}}
1110 {{/code}}
1111
1112 The calling it for example with the following URL ##http:~/~/localhost:8080/xwiki/bin/get/GetChildren/?space=Sandbox&xpage=plain&outputSyntax=plain## would give something like:
1113
1114 {{code language="none"}}
1115 <pages>
1116 <page>Sandbox.Test.WebHome</page>
1117 <page>Sandbox.TestPage2</page>
1118 <page>Sandbox.ApplicationsPanelEntry</page>
1119 <page>Sandbox.TestPage3</page>
1120 <page>Sandbox.TestPage1</page>
1121 <page>Sandbox.WebPreferences</page>
1122 <page>Sandbox.WebHome</page>
1123 </pages>
1124 {{/code}}
1125
1126 == In Java ==
1127
1128 It's possible to easily add any REST resource by registering a ##org.xwiki.rest.XWikiResource## java component on your wiki (see [[Component guide>>Documentation.DevGuide.Tutorials.WritingComponents]] for more details).
1129
1130 {{code language="java"}}
1131 package org.xwiki.contrib.rest;
1132
1133 import javax.ws.rs.DefaultValue;
1134 import javax.ws.rs.GET;
1135 import javax.ws.rs.Path;
1136
1137 import org.xwiki.component.annotation.Component;
1138 import org.xwiki.rest.XWikiResource;
1139
1140 @Component("org.xwiki.contrib.rest.HelloWorldResource")
1141 @Path("/myresources/{myresourcename}")
1142 public class HelloWorldResource extends XWikiResource {
1143 @GET
1144 public String get(@PathParam("myresourcename") @DefaultValue("world") String myresourcename)
1145 {
1146 return "Hello " + myresourcename;
1147 }
1148 }
1149 {{/code}}
1150
1151 The name of the component has to be the class FQN.
1152
1153 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]].
1154
1155 The resource is expected to follow JAX-RS 1 specifications before XWiki 16.2.0 and JAX-RS 2.1 starting with XWiki 16.2.0.
1156
1157 Starting from release 4.3M2, the RESTful API modules have been refactored so that now resource declarations are available in a separate module.
1158 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.
1159
1160 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:
1161
1162 * Another platform module that wants to generate responses with links to existing resources.
1163 * HTTP clients that wants to make requests to the RESTful API.
1164
1165 The xwiki-platform-rest-api module can be also seen as an authoritative reference for the REST API.
1166
1167 = Generate a REST URL for a resource =
1168
1169 If you need to generate a REST URL as String for a resource inside a script, you can use the REST script services:
1170
1171 {{code language="velocity"}}
1172 ## Return a relative URL String unless the reference wiki is different from the current wiki
1173 $services.rest.url($entityReference)
1174
1175 ## Force returning an external form URL String, false as second parameter would have the same effect that the previous call
1176 $services.rest.url($entityReference, true)
1177
1178 ## String parameter automaticallly converter to entity reference
1179 $services.rest.url('MySpace.MyPage')
1180 $services.rest.url('document:MySpace.MyPage')
1181 $services.rest.url('space:MySpace')
1182 {{/code}}
1183
1184 Where ##$entityReference## could be:
1185
1186 * a ##DocumentReference##
1187 * a ##SpaceReference##
1188
1189 We plan to add more supported entities in the future (ObjectReference, ClassReference, etc...).
1190
1191 = Using the RESTful API =
1192
1193 {{info}}
1194 The examples below are using the ##~-~-data## (##-d##) parameter of the curl command to provide the data sent with the request, which may do some alteration on the content being actually sent (newlines, character set, etc.)
1195 There may be cases where you may need / want to use the ##~-~-data-binary## parameter, in order to send the data as-is, especially when manipulating page content, in which the newlines are relevant.
1196 {{/info}}
1197
1198 == Tutorial ==
1199
1200 See [[this tutorial>>http://blog.fabio.mancinelli.me/2011/03/07/XWikis_RESTful_API.html]] by Fabio Mancinelli.
1201
1202 == Creating an XWiki Object ==
1203
1204 In this example we will use the [[curl>>http://curl.haxx.se/]] utility as the HTTP client.
1205
1206 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##.
1207
1208 So, on the command line, you have to do the following:
1209
1210 {{code}}
1211 $ curl -u Admin:admin
1212 -X POST
1213 -H "Content-type: application/xml"
1214 -H "Accept: application/xml"
1215 -d "@test.xml"
1216 http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects
1217 {{/code}}
1218
1219 where ##test.xml## is:
1220
1221 {{code language="xml"}}
1222 <object xmlns="http://www.xwiki.org">
1223 <className>XWiki.TestClass</className>
1224 <property name="text">
1225 <value>Whatever you want to put here</value>
1226 </property>
1227 </object>
1228 {{/code}}
1229
1230 Alternatively you can use the less verbose ##application/x-www-form-urlencoded format##:
1231
1232 {{code}}
1233 $ curl -u Admin:admin
1234 -X POST
1235 -H "Content-type: application/x-www-form-urlencoded"
1236 -H "Accept: application/xml"
1237 -d "@test.txt"
1238 http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects
1239 {{/code}}
1240
1241 where ##test.txt## contains something like:
1242
1243 {{code}}
1244 className=XWiki.TestClass&property#test=Whatever+you+want
1245 {{/code}}
1246
1247 Or, better, you can use directly curl to specify these parameters
1248 using multiple ##-d## switches:
1249
1250 {{code}}
1251 $ curl -u Admin:admin
1252 -X POST -H "Content-type: application/x-www-form-urlencoded"
1253 -H "Accept: application/xml"
1254 -d "className=XWiki.TestClass"
1255 -d "property#test=Whatever you want"
1256 http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects
1257 {{/code}}
1258
1259 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.
1260
1261 === Remarks: ===
1262
1263 * 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.
1264
1265 * The information you get back when you retrieve an object (i.e., all
1266 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.
1267
1268 * 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.
1269
1270 == Formats of files ==
1271
1272 A XSD schema exists for XWiki (look [[here>>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]] for the source).
1273
1274 However, you may not know exactly how to write the XML files to use when using the PUT method. First thing to know, you may try to get examples by using ##GET## HTTP request to the REST service using cURL or similar tools.
1275
1276 But in order to help you, you'll find below the different formats that you can use. Note that the following XML files are exhaustive files but not all the elements are required.
1277
1278 === Example of a file for a ##wiki## ===
1279
1280 {{code language="xml"}}
1281
1282 <wiki xmlns="http://www.xwiki.org">
1283 <id>xwiki</id>
1284 <name>xwiki</name>
1285 <description>Some description of the wiki</description>
1286 <owner>Admin</owner>
1287 </wiki>
1288 {{/code}}
1289
1290 === Example of a file for a ##space## ===
1291
1292 {{code language="xml"}}
1293
1294 <space xmlns="http://www.xwiki.org">
1295 <id>xwiki:Main</id>
1296 <wiki>xwiki</wiki>
1297 <name>Main</name>
1298 <home>xwiki:Main.WebHome</home>
1299 <xwikiRelativeUrl>http://localhost:8080/xwiki/bin/view/Main/</xwikiRelativeUrl>
1300 <xwikiAbsoluteUrl>http://localhost:8080/xwiki/bin/view/Main/</xwikiAbsoluteUrl>
1301 </space>
1302 {{/code}}
1303
1304 === Example of a file for a ##page## ===
1305
1306 {{code language="xml"}}
1307
1308 <page xmlns="http://www.xwiki.org">
1309 <id>xwiki:Main.WebHome</id>
1310 <fullName>Main.WebHome</fullName>
1311 <wiki>xwiki</wiki>
1312 <space>Main</space>
1313 <name>WebHome</name>
1314 <title>Home</title>
1315 <parent></parent>
1316 <parentId></parentId>
1317 <version>1.1</version>
1318 <author>XWiki.Admin</author>
1319 <authorName>Administrator</authorName>
1320 <xwikiRelativeUrl>http://localhost:8080/xwiki/bin/view/Main/</xwikiRelativeUrl>
1321 <xwikiAbsoluteUrl>http://localhost:8080/xwiki/bin/view/Main/</xwikiAbsoluteUrl>
1322 <translations></translations>
1323 <syntax>xwiki/2.0</syntax>
1324 <language></language>
1325 <majorVersion>1</majorVersion>
1326 <minorVersion>1</minorVersion>
1327 <hidden>false</hidden>
1328 <created>2009-09-09T02:00:00+02:00</created>
1329 <creator>XWiki.Admin</creator>
1330 <creatorName>Administrator</creatorName>
1331 <modified>2015-10-29T11:19:02+01:00</modified>
1332 <modifier>XWiki.Admin</modifier>
1333 <modifierName>Administrator</modifierName>
1334 <comment>Imported from XAR</comment>
1335 <content>{{include reference="Dashboard.WebHome" context="new"/}}</content>
1336 </page>
1337 {{/code}}
1338
1339 === Example of a file for a ##tag## ===
1340
1341 {{code language="xml"}}
1342 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1343 <tags xmlns="http://www.xwiki.org">
1344 <tag name="food"></tag>
1345 </tags>
1346 {{/code}}
1347
1348 === Example of a file for a ##comment## ===
1349
1350 {{code language="xml"}}
1351 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1352 <comments xmlns="http://www.xwiki.org">
1353 <comment>
1354 <id>0</id>
1355 <pageId>xwiki:Main.WebHome</pageId>
1356 <author>XWiki.Admin</author>
1357 <authorName>Administrator</authorName>
1358 <date>2015-11-13T18:20:51.936+01:00</date>
1359 <highlight></highlight>
1360 <text>This is a comment</text>
1361 <replyTo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"></replyTo>
1362 </comment>
1363 </comments>
1364 {{/code}}
1365
1366 === Example of a file for an ##object## ===
1367
1368 {{code language="xml"}}
1369 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1370 <object xmlns="http://www.xwiki.org">
1371 <id>xwiki:Main.WebHome:c170a0a8-cc17-41cd-aa1e-6f6faf1d9f28</id>
1372 <guid>c170a0a8-cc17-41cd-aa1e-6f6faf1d9f28</guid>
1373 <pageId>xwiki:Main.WebHome</pageId>
1374 <pageVersion>1.1</pageVersion>
1375 <wiki>xwiki</wiki>
1376 <space>Main</space>
1377 <pageName>WebHome</pageName>
1378 <pageAuthor>XWiki.superadmin</pageAuthor>
1379 <className>XWiki.EditModeClass</className>
1380 <number>0</number>
1381 <headline>edit</headline>
1382 <property name="defaultEditMode" type="String">
1383 <attribute name="name" value="defaultEditMode"></attribute>
1384 <attribute name="prettyName" value="Default Edit Mode"></attribute>
1385 <attribute name="unmodifiable" value="0"></attribute>
1386 <attribute name="disabled" value="0"></attribute>
1387 <attribute name="size" value="15"></attribute>
1388 <attribute name="number" value="1"></attribute>
1389 <value>edit</value>
1390 </property>
1391 </object>
1392 {{/code}}
1393
1394 === Example of a file for a ##property## ===
1395
1396 {{code language="xml"}}
1397 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1398 <property xmlns="http://www.xwiki.org" name="defaultEditMode" type="String">
1399 <attribute name="name" value="defaultEditMode"></attribute>
1400 <attribute name="prettyName" value="Default Edit Mode"></attribute>
1401 <attribute name="unmodifiable" value="0"></attribute>
1402 <attribute name="disabled" value="0"></attribute>
1403 <attribute name="size" value="15"></attribute>
1404 <attribute name="number" value="1"></attribute>
1405 <value>edit</value>
1406 </property>
1407 {{/code}}
1408
1409 = Examples =
1410
1411 == Getting the list of users ==
1412
1413 Since Users are stored as Objects, you can do a search of the type ##XWiki.XWikiUsers##. For example:
1414
1415 {{code}}
1416 http://<server>/xwiki/rest/wikis/query?q=object:XWiki.XWikiUsers
1417 {{/code}}
1418
1419 == Getting the list of users using XWQL ==
1420
1421 Using the parameter "className" the result includes the data for the first object of the ##XWiki.XWikiUsers##:
1422
1423 {{code}}
1424 http://<server>/xwiki/rest/wikis/xwiki/query?q=,doc.object(XWiki.XWikiUsers) as obj&type=xwql&className=XWiki.XWikiUsers
1425 {{/code}}
1426
1427 == Getting the list of inactive users using XWQL ==
1428
1429 Using the property "active" where the value is 0 (by replacing with value 1 result will include active users) the result includes the data for all objects of the ##XWiki.XWikiUsers##:
1430
1431 {{code}}
1432 http://<server>/xwiki/rest/wikis/xwiki/query?q=where doc.object(XWiki.XWikiUsers).active=0&type=xwql&className=XWiki.XWikiUsers
1433 {{/code}}

Get Connected