Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -12,7 +12,7 @@ 12 12 13 13 {{/code}} 14 14 15 -All the resource references described in the [[XWiki RESTful API Documentation>> http://platform.xwiki.org/xwiki/bin/view/Features/XWikiRESTfulAPI#HXWikiRESTfulAPIDocumentation]] should be intended relative to this URL.15 +All the resource references described in the [[XWiki RESTful API Documentation>>#HXWikiRESTfulAPIDocumentation]] should be intended relative to this URL. 16 16 17 17 For example the, 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## 18 18 ... ... @@ -82,10 +82,18 @@ 82 82 83 83 If you use this approach (Apache HTTP Client + JAXB) you will find yourself writing some code like this: 84 84 85 -{{code language="none"}} 85 +{{code language="java"}} 86 +import javax.xml.bind.JAXBContext; 87 +import javax.xml.bind.Unmarshaller; 88 + 89 +import org.apache.commons.httpclient.HttpClient; 90 +import org.apache.commons.httpclient.methods.GetMethod; 91 +import org.xwiki.rest.model.jaxb.Page; 92 + 93 +... 86 86 HttpClient httpClient = new HttpClient(); 87 -JAXBContext context = JAXBContext.newInstance("model. package");88 -unmarshaller = context.createUnmarshaller(); 95 +JAXBContext context = JAXBContext.newInstance("org.xwiki.rest.model.jaxb"); 96 +Unmarshaller unmarshaller = context.createUnmarshaller(); 89 89 90 90 GetMethod getMethod = new GetMethod("http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome"); 91 91 getMethod.addRequestHeader("Accept", "application/xml"); ... ... @@ -100,7 +100,7 @@ 100 100 101 101 By using curl, the previous example would have been: 102 102 103 -{{code language=" none"}}111 +{{code language="xml"}} 104 104 $ curl http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/WebHome 105 105 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 106 106 <page xmlns="http://www.xwiki.org"> ... ... @@ -130,7 +130,7 @@ 130 130 131 131 On the contrary, by specifying Admin credentials you gain access to the actual page: 132 132 133 -{{code language=" none"}}141 +{{code language="xml"}} 134 134 $ curl -u Admin:admin http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/PrivatePage 135 135 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 136 136 <page xmlns="http://www.xwiki.org"> ... ... @@ -149,7 +149,7 @@ 149 149 150 150 For example, in order to create a page you might do the following: 151 151 152 -{{code language=" none"}}160 +{{code language="xml"}} 153 153 $ curl -u Admin:admin -X PUT -d "@newpage.xml" -H "Content-Type: application/xml" http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Main/pages/NewPage 154 154 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 155 155 <page xmlns="http://www.xwiki.org"> ... ... @@ -168,7 +168,7 @@ 168 168 169 169 Where newpage.xml is an XML file containing 170 170 171 -{{code language=" none"}}179 +{{code language="xml"}} 172 172 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 173 173 <page xmlns="http://www.xwiki.org"> 174 174 <title>Hello world</title>