Wiki source code of REST API

Version 101.1 by slauriere on 2024/09/11

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

Get Connected