Rest WikiPages » History » Version 5

Máté Katona, 2015-11-04 09:35

1 1 Jean-Philippe Lang
h1. Wiki Pages
2 1 Jean-Philippe Lang
3 1 Jean-Philippe Lang
{{>toc}}
4 1 Jean-Philippe Lang
5 1 Jean-Philippe Lang
h2. Getting the pages list of a wiki
6 1 Jean-Philippe Lang
7 1 Jean-Philippe Lang
<pre>
8 1 Jean-Philippe Lang
GET /projects/foo/wiki/index.xml
9 1 Jean-Philippe Lang
</pre>
10 1 Jean-Philippe Lang
11 1 Jean-Philippe Lang
Returns the list of all pages in a project wiki.
12 1 Jean-Philippe Lang
13 1 Jean-Philippe Lang
+Response+:
14 1 Jean-Philippe Lang
15 1 Jean-Philippe Lang
<pre>
16 1 Jean-Philippe Lang
<?xml version="1.0"?>
17 1 Jean-Philippe Lang
<wiki_pages type="array">
18 1 Jean-Philippe Lang
  <wiki_page>
19 1 Jean-Philippe Lang
    <title>UsersGuide</title>
20 1 Jean-Philippe Lang
    <version>2</version>
21 1 Jean-Philippe Lang
    <created_on>2008-03-09T12:07:08Z</created_on>
22 1 Jean-Philippe Lang
    <updated_on>2008-03-09T23:41:33+01:00</updated_on>
23 1 Jean-Philippe Lang
  </wiki_page>
24 1 Jean-Philippe Lang
  ...
25 1 Jean-Philippe Lang
</wiki_pages>
26 1 Jean-Philippe Lang
</pre>
27 1 Jean-Philippe Lang
28 1 Jean-Philippe Lang
h2. Getting a wiki page
29 1 Jean-Philippe Lang
30 1 Jean-Philippe Lang
<pre>
31 1 Jean-Philippe Lang
GET /projects/foo/wiki/UsersGuide.xml
32 1 Jean-Philippe Lang
</pre>
33 1 Jean-Philippe Lang
34 1 Jean-Philippe Lang
Returns the details of a wiki page.
35 1 Jean-Philippe Lang
36 1 Jean-Philippe Lang
+Includable+:
37 1 Jean-Philippe Lang
* attachments
38 1 Jean-Philippe Lang
39 1 Jean-Philippe Lang
+Response+:
40 1 Jean-Philippe Lang
41 1 Jean-Philippe Lang
<pre>
42 1 Jean-Philippe Lang
<?xml version="1.0"?>
43 1 Jean-Philippe Lang
<wiki_page>
44 1 Jean-Philippe Lang
  <title>UsersGuide</title>
45 1 Jean-Philippe Lang
  <parent title="Installation_Guide"/>
46 1 Jean-Philippe Lang
  <text>h1. Users Guide
47 1 Jean-Philippe Lang
  ...
48 1 Jean-Philippe Lang
  ...</text>
49 1 Jean-Philippe Lang
  <version>22</version>
50 1 Jean-Philippe Lang
  <author id="11" name="John Smith"/>
51 1 Jean-Philippe Lang
  <comments>Typo</comments>
52 1 Jean-Philippe Lang
  <created_on>2009-05-18T20:11:52Z</created_on>
53 1 Jean-Philippe Lang
  <updated_on>2012-10-02T11:38:18Z</updated_on>
54 1 Jean-Philippe Lang
</wiki_page>
55 1 Jean-Philippe Lang
</pre>
56 1 Jean-Philippe Lang
57 3 Jean-Philippe Lang
h2. Getting an old version of a wiki page
58 3 Jean-Philippe Lang
59 3 Jean-Philippe Lang
<pre>
60 3 Jean-Philippe Lang
GET /projects/foo/wiki/UsersGuide/23.xml
61 3 Jean-Philippe Lang
</pre>
62 3 Jean-Philippe Lang
63 3 Jean-Philippe Lang
Returns the details of an old version of a wiki page.
64 3 Jean-Philippe Lang
65 3 Jean-Philippe Lang
+Includable+:
66 3 Jean-Philippe Lang
* attachments
67 3 Jean-Philippe Lang
68 3 Jean-Philippe Lang
+Response+:
69 3 Jean-Philippe Lang
70 3 Jean-Philippe Lang
Same as above.
71 3 Jean-Philippe Lang
72 1 Jean-Philippe Lang
h2. Creating or updating a wiki page
73 1 Jean-Philippe Lang
74 1 Jean-Philippe Lang
<pre>
75 1 Jean-Philippe Lang
PUT /projects/foo/wiki/UsersGuide.xml
76 1 Jean-Philippe Lang
<?xml version="1.0"?>
77 1 Jean-Philippe Lang
<wiki_page>
78 1 Jean-Philippe Lang
  <text>Example</text>
79 1 Jean-Philippe Lang
  <comments>Typo</comments>
80 4 Kevin Saliou
</wiki_page>
81 1 Jean-Philippe Lang
</pre>
82 1 Jean-Philippe Lang
83 1 Jean-Philippe Lang
Creates or updates a wiki page.
84 1 Jean-Philippe Lang
85 1 Jean-Philippe Lang
When updating an existing page, you can include a @version@ attribute to make sure that the page is a specific version when you try to update it (eg. you don't want to overwrite an update that would have been done after you retrieved the page). Example:
86 1 Jean-Philippe Lang
87 1 Jean-Philippe Lang
<pre>
88 1 Jean-Philippe Lang
PUT /projects/foo/wiki/UsersGuide.xml
89 1 Jean-Philippe Lang
<?xml version="1.0"?>
90 1 Jean-Philippe Lang
<wiki_page>
91 1 Jean-Philippe Lang
  <text>Example</text>
92 1 Jean-Philippe Lang
  <comments>Typo</comments>
93 1 Jean-Philippe Lang
  <version>18</version>
94 4 Kevin Saliou
</wiki_page>
95 1 Jean-Philippe Lang
</pre>
96 1 Jean-Philippe Lang
97 1 Jean-Philippe Lang
This would update the page if its current version is 18, otherwise a @409 Conflict@ error is returned.
98 1 Jean-Philippe Lang
99 1 Jean-Philippe Lang
100 5 Máté Katona
101 5 Máté Katona
h3. Attaching files
102 5 Máté Katona
103 5 Máté Katona
+JSON example+
104 5 Máté Katona
105 5 Máté Katona
First, upload your file(s):
106 5 Máté Katona
107 5 Máté Katona
<pre>
108 5 Máté Katona
POST /uploads.json
109 5 Máté Katona
Content-Type: application/octet-stream
110 5 Máté Katona
...
111 5 Máté Katona
(request body is the file content)
112 5 Máté Katona
113 5 Máté Katona
# 201 response
114 5 Máté Katona
{"upload":{"token":"7167.ed1ccdb093229ca1bd0b043618d88743"}}
115 5 Máté Katona
</pre>
116 5 Máté Katona
117 5 Máté Katona
If you want to attach more than one file, upload them one by one, and save all the tokens.
118 5 Máté Katona
Then create/update the wiki page using the attachments token (with one or more files provided as an array of objects):
119 5 Máté Katona
120 5 Máté Katona
<pre>
121 5 Máté Katona
PUT /projects/project_name/wiki/wiki_name.json
122 5 Máté Katona
{
123 5 Máté Katona
    "wiki_page": {
124 5 Máté Katona
        "text": "This is a wiki page with images (like this: !img.png!), and other files."
125 5 Máté Katona
    },
126 5 Máté Katona
    "attachments": [
127 5 Máté Katona
        {"token": "7167.ed1ccdb093229ca1bd0b043618d88743", "filename": "img.bmp", "content-type": "image/png"},
128 5 Máté Katona
        {"token": "7168.d595398bbb104ed3bba0eed666785cc6", "filename": "document.pdf", "content-type": "application/pdf"}
129 5 Máté Katona
    ]
130 5 Máté Katona
}
131 5 Máté Katona
</pre>
132 5 Máté Katona
133 5 Máté Katona
+Note:+
134 5 Máté Katona
135 5 Máté Katona
When creating or updating wiki pages, the text field must be provided, otherwise you will get a @422 Unprocessable Entity@ error saying: "Text field can't be blank".
136 5 Máté Katona
If you do not wish to change the text, you can keep it by first getting the wiki page as described above, and provide the current text in the update.
137 5 Máté Katona
138 5 Máté Katona
139 5 Máté Katona
140 1 Jean-Philippe Lang
+Response+:
141 1 Jean-Philippe Lang
* @200 OK@: page was updated
142 1 Jean-Philippe Lang
* @201 Created@: page was created
143 1 Jean-Philippe Lang
* @409 Conflict@: occurs when trying to update a stale page (see above)
144 1 Jean-Philippe Lang
* @422 Unprocessable Entity@: page was not saved due to validation failures (response body contains the error messages)
145 2 Jean-Philippe Lang
146 2 Jean-Philippe Lang
h2. Deleting a wiki page
147 2 Jean-Philippe Lang
148 2 Jean-Philippe Lang
<pre>
149 2 Jean-Philippe Lang
DELETE /projects/foo/wiki/UsersGuide.xml
150 2 Jean-Philippe Lang
</pre>
151 2 Jean-Philippe Lang
152 2 Jean-Philippe Lang
Deletes a wiki page, its attachments and its history. If the deleted page is a parent page, its child pages are not deleted but changed as root pages.
153 2 Jean-Philippe Lang
154 2 Jean-Philippe Lang
+Response+:
155 2 Jean-Philippe Lang
* @200 OK@: page was deleted