Project

General

Profile

Rest WikiPages » History » Version 5

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

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