Wiki source code of REST API

Version 107.1 by Marius Dumitru Florea on 2025/02/07

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

Get Connected