Wiki source code of REST API

Last modified by Ludovic Dubost on 2021/06/24

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

Get Connected