Changes for page REST API

Last modified by Thomas Mortagne on 2024/03/12

<
From version < 67.1 >
edited by Thomas Mortagne
on 2017/04/26
To version < 70.1 >
edited by Vincent Massol
on 2017/09/06
>
Change comment: Copied from platform:Features.XWikiRESTfulAPI

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.ThomasMortagne
1 +XWiki.VincentMassol
Content
... ... @@ -300,7 +300,7 @@
300 300  ** **Status codes:**
301 301  *** 200: If the request was successful.
302 302  
303 -=== /wikimanager (This resource is only available when using XWiki Enterprise Manager) ===
303 +=== /wikimanager (This resource is only available when using the [[multi-wiki>>extensions:Extension.Wiki Application]] feature) ===
304 304  
305 305  * **HTTP Method:** POST
306 306  ** **Accepted Media types:**
... ... @@ -944,10 +944,10 @@
944 944  
945 945  * current wiki
946 946  * current user
947 -* current document
948 -* current secure document
949 949  * request URL and parameters
950 950  
949 +Since 9.7RC1 failing jobs with ##async=false## return an error 500.
950 +
951 951  * **HTTP Method:** PUT
952 952  ** **Accepted Media types:**
953 953  *** application/xml (JobRequest element)
... ... @@ -1033,7 +1033,7 @@
1033 1033  
1034 1034  = Using the RESTful API =
1035 1035  
1036 -== Highlevel description and tutorial for a basic usage of the RESTful API ==
1036 +== Tutorial ==
1037 1037  
1038 1038  See [[this tutorial>>http://blog.fabio.mancinelli.me/2011/03/07/XWikis_RESTful_API.html]] by Fabio Mancinelli.
1039 1039  
... ... @@ -1105,6 +1105,145 @@
1105 1105  
1106 1106  * 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.
1107 1107  
1108 +== Formats of files ==
1109 +
1110 +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).
1111 +
1112 +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.
1113 +
1114 +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.
1115 +
1116 +=== Example of a file for a ##wiki## ===
1117 +
1118 +{{code language="xml"}}
1119 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1120 +<wiki xmlns="http://www.xwiki.org">
1121 + <id>xwiki</id>
1122 + <name>xwiki</name>
1123 + <description>Some description of the wiki</description>
1124 + <owner>Admin</owner>
1125 +</wiki>
1126 +{{/code}}
1127 +
1128 +=== Example of a file for a ##space## ===
1129 +
1130 +{{code language="xml"}}
1131 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1132 +<space xmlns="http://www.xwiki.org">
1133 + <id>xwiki:Main</id>
1134 + <wiki>xwiki</wiki>
1135 + <name>Main</name>
1136 + <home>xwiki:Main.WebHome</home>
1137 + <xwikiRelativeUrl>http://localhost:8080/xwiki/bin/view/Main/</xwikiRelativeUrl>
1138 + <xwikiAbsoluteUrl>http://localhost:8080/xwiki/bin/view/Main/</xwikiAbsoluteUrl>
1139 +</space>
1140 +{{/code}}
1141 +
1142 +=== Example of a file for a ##page## ===
1143 +
1144 +{{code language="xml"}}
1145 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1146 +<page xmlns="http://www.xwiki.org">
1147 + <id>xwiki:Main.WebHome</id>
1148 + <fullName>Main.WebHome</fullName>
1149 + <wiki>xwiki</wiki>
1150 + <space>Main</space>
1151 + <name>WebHome</name>
1152 + <title>Home</title>
1153 + <parent/>
1154 + <parentId/>
1155 + <version>1.1</version>
1156 + <author>XWiki.Admin</author>
1157 + <authorName>Administrator</authorName>
1158 + <xwikiRelativeUrl>http://localhost:8080/xwiki/bin/view/Main/</xwikiRelativeUrl>
1159 + <xwikiAbsoluteUrl>http://localhost:8080/xwiki/bin/view/Main/</xwikiAbsoluteUrl>
1160 + <translations/>
1161 + <syntax>xwiki/2.0</syntax>
1162 + <language/>
1163 + <majorVersion>1</majorVersion>
1164 + <minorVersion>1</minorVersion>
1165 + <hidden>false</hidden>
1166 + <created>2009-09-09T02:00:00+02:00</created>
1167 + <creator>XWiki.Admin</creator>
1168 + <creatorName>Administrator</creatorName>
1169 + <modified>2015-10-29T11:19:02+01:00</modified>
1170 + <modifier>XWiki.Admin</modifier>
1171 + <modifierName>Administrator</modifierName>
1172 + <comment>Imported from XAR</comment>
1173 + <content>{{include reference="Dashboard.WebHome" context="new"/}}</content>
1174 +</page>
1175 +{{/code}}
1176 +
1177 +=== Example of a file for a ##tag## ===
1178 +
1179 +{{code language="xml"}}
1180 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1181 +<tags xmlns="http://www.xwiki.org">
1182 + <tag name="food"></tag>
1183 +</tags>
1184 +{{/code}}
1185 +
1186 +=== Example of a file for a ##comment## ===
1187 +
1188 +{{code language="xml"}}
1189 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1190 +<comments xmlns="http://www.xwiki.org">
1191 + <comment>
1192 + <id>0</id>
1193 + <pageId>xwiki:Main.WebHome</pageId>
1194 + <author>XWiki.Admin</author>
1195 + <authorName>Administrator</authorName>
1196 + <date>2015-11-13T18:20:51.936+01:00</date>
1197 + <highlight/>
1198 + <text>This is a comment</text>
1199 + <replyTo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
1200 + </comment>
1201 +</comments>
1202 +{{/code}}
1203 +
1204 +=== Example of a file for an ##object## ===
1205 +
1206 +{{code language="xml"}}
1207 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1208 +<object xmlns="http://www.xwiki.org">
1209 + <id>xwiki:Main.WebHome:c170a0a8-cc17-41cd-aa1e-6f6faf1d9f28</id>
1210 + <guid>c170a0a8-cc17-41cd-aa1e-6f6faf1d9f28</guid>
1211 + <pageId>xwiki:Main.WebHome</pageId>
1212 + <pageVersion>1.1</pageVersion>
1213 + <wiki>xwiki</wiki>
1214 + <space>Main</space>
1215 + <pageName>WebHome</pageName>
1216 + <pageAuthor>XWiki.superadmin</pageAuthor>
1217 + <className>XWiki.EditModeClass</className>
1218 + <number>0</number>
1219 + <headline>edit</headline>
1220 + <property name="defaultEditMode" type="String">
1221 + <attribute name="name" value="defaultEditMode"/>
1222 + <attribute name="prettyName" value="Default Edit Mode"/>
1223 + <attribute name="unmodifiable" value="0"/>
1224 + <attribute name="disabled" value="0"/>
1225 + <attribute name="size" value="15"/>
1226 + <attribute name="number" value="1"/>
1227 + <value>edit</value>
1228 + </property>
1229 +</object>
1230 +{{/code}}
1231 +
1232 +=== Example of a file for a ##property## ===
1233 +
1234 +{{code language="xml"}}
1235 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1236 +<property xmlns="http://www.xwiki.org" name="defaultEditMode" type="String">
1237 + <attribute name="name" value="defaultEditMode"/>
1238 + <attribute name="prettyName" value="Default Edit Mode"/>
1239 + <attribute name="unmodifiable" value="0"/>
1240 + <attribute name="disabled" value="0"/>
1241 + <attribute name="size" value="15"/>
1242 + <attribute name="number" value="1"/>
1243 + <value>edit</value>
1244 +</property>
1245 +{{/code}}
1246 +
1108 1108  = Examples =
1109 1109  
1110 1110  == Getting the list of users ==
XWiki.XWikiComments[3]
Comment
... ... @@ -1,9 +1,5 @@
1 1  In Eclipse, you can right click on an xsd file, like the xsd for the REST api [[described here>>XWikiRESTfulAPI#HXWikiRESTfulAPIDocumentation]], and choose "Generate->JAXB classes".
2 2  
3 3  Whatever package that you choose to generate them in, you would use in the
4 -{{code language="java"}}
5 -context = JAXBContext.newInstance("org");
6 -{{/code}}
4 +{{code language="java"}}context = JAXBContext.newInstance("org");{{/code}}
7 7   In the examples I gave, I just generated them under a package called "org", mostly due to extreme laziness. So I ended up with org.Page, org.ObjectFactory, org.Space and so on.
8 -
9 -
XWiki.XWikiComments[6]
Comment
... ... @@ -5,4 +5,3 @@
5 5  
6 6  This allows to render the XWiki HTML content in a third party system, while keeping the content management in XWiki.
7 7  Perhaps this helps from manual translation of XWiki to HTML
8 -

Get Connected