Skip to content

Commit b95b7f7

Browse files
author
snippetbucket
committed
SnippetBucket.com added test json API calls
1 parent fe72912 commit b95b7f7

File tree

4 files changed

+369
-0
lines changed

4 files changed

+369
-0
lines changed

Confluence.postman_collection.json

Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
{
2+
"id": "39953387-3711-f272-1ab4-3da1c21b3f0c",
3+
"name": "Confluence",
4+
"description": "",
5+
"order": [
6+
"fb6b35e4-4168-0f92-75d6-2a04113b755f",
7+
"53f9e44a-1eb6-3e23-9f3b-d1e4a6c5c30d",
8+
"60e22a64-dc2f-a1dc-af08-b8c3e581da12",
9+
"6f08c5a7-47e5-cf42-5304-aed6b920e99a",
10+
"8cd10775-0a75-43e1-fb8f-406c6ed18fd3",
11+
"503618ca-af43-4cbb-fd34-ceea80aa80ca",
12+
"6e0a2545-a7d3-955f-45ac-67a643aa15ad",
13+
"b01e8ce2-d8f9-de03-655e-5f7f59b2a25e"
14+
],
15+
"folders": [],
16+
"folders_order": [],
17+
"timestamp": 1548416617092,
18+
"owner": 0,
19+
"public": false,
20+
"requests": [
21+
{
22+
"id": "503618ca-af43-4cbb-fd34-ceea80aa80ca",
23+
"headers": "Content-Type: application/json\nAuthorization: Basic dGVzdDE6c2JAMTIz\n",
24+
"headerData": [
25+
{
26+
"key": "Content-Type",
27+
"value": "application/json",
28+
"description": "",
29+
"enabled": true
30+
},
31+
{
32+
"key": "Authorization",
33+
"value": "Basic dGVzdDE6c2JAMTIz",
34+
"description": "",
35+
"enabled": true
36+
}
37+
],
38+
"url": "https://192.168.1.119//rest/api/space",
39+
"queryParams": [],
40+
"preRequestScript": null,
41+
"pathVariables": {},
42+
"pathVariableData": [],
43+
"method": "GET",
44+
"data": [],
45+
"dataMode": "raw",
46+
"version": 2,
47+
"tests": null,
48+
"currentHelper": "normal",
49+
"helperAttributes": {},
50+
"time": 1548422458476,
51+
"name": "Get Space",
52+
"description": "",
53+
"collectionId": "39953387-3711-f272-1ab4-3da1c21b3f0c",
54+
"responses": [],
55+
"rawModeData": ""
56+
},
57+
{
58+
"id": "53f9e44a-1eb6-3e23-9f3b-d1e4a6c5c30d",
59+
"headers": "",
60+
"headerData": [],
61+
"url": "",
62+
"queryParams": [],
63+
"pathVariables": {},
64+
"pathVariableData": [],
65+
"preRequestScript": null,
66+
"method": "GET",
67+
"collectionId": "39953387-3711-f272-1ab4-3da1c21b3f0c",
68+
"data": null,
69+
"dataMode": "params",
70+
"name": "Login auth",
71+
"description": "",
72+
"descriptionFormat": "html",
73+
"time": 1548416950347,
74+
"version": 2,
75+
"responses": [],
76+
"tests": null,
77+
"currentHelper": "normal",
78+
"helperAttributes": {}
79+
},
80+
{
81+
"id": "60e22a64-dc2f-a1dc-af08-b8c3e581da12",
82+
"headers": "Content-Type: application/json\nAuthorization: Basic dGVzdDE6c2JAMTIz\n",
83+
"headerData": [
84+
{
85+
"key": "Content-Type",
86+
"value": "application/json",
87+
"description": "",
88+
"enabled": true
89+
},
90+
{
91+
"key": "Authorization",
92+
"value": "Basic dGVzdDE6c2JAMTIz",
93+
"description": "",
94+
"enabled": true
95+
}
96+
],
97+
"url": "https://192.168.1.119/rest/api/content/",
98+
"queryParams": [],
99+
"pathVariables": {},
100+
"pathVariableData": [],
101+
"preRequestScript": null,
102+
"method": "POST",
103+
"collectionId": "39953387-3711-f272-1ab4-3da1c21b3f0c",
104+
"data": [],
105+
"dataMode": "raw",
106+
"name": "Login auth",
107+
"description": "",
108+
"descriptionFormat": "html",
109+
"time": 1548417613597,
110+
"version": 2,
111+
"responses": [],
112+
"tests": null,
113+
"currentHelper": "normal",
114+
"helperAttributes": {},
115+
"rawModeData": " {\"type\":\"page\",\n \"title\":\"My Test Page\",\n \"space\":{\"key\":\"SB\"},\n \"body\":{\"storage\":{\"value\":\"<p>This is a new page</p>\",\"representation\":\"storage\"}}}"
116+
},
117+
{
118+
"id": "6e0a2545-a7d3-955f-45ac-67a643aa15ad",
119+
"headers": "Content-Type: application/json\nAuthorization: Basic dGVzdDE6c2JAMTIz\n",
120+
"headerData": [
121+
{
122+
"key": "Content-Type",
123+
"value": "application/json",
124+
"description": "",
125+
"enabled": true
126+
},
127+
{
128+
"key": "Authorization",
129+
"value": "Basic dGVzdDE6c2JAMTIz",
130+
"description": "",
131+
"enabled": true
132+
}
133+
],
134+
"url": "https://192.168.1.119//rest/api/space",
135+
"queryParams": [],
136+
"preRequestScript": null,
137+
"pathVariables": {},
138+
"pathVariableData": [],
139+
"method": "POST",
140+
"data": [],
141+
"dataMode": "raw",
142+
"version": 2,
143+
"tests": null,
144+
"currentHelper": "normal",
145+
"helperAttributes": {},
146+
"time": 1548422494272,
147+
"name": "Create Space",
148+
"description": "",
149+
"collectionId": "39953387-3711-f272-1ab4-3da1c21b3f0c",
150+
"responses": [],
151+
"rawModeData": "{\n \"key\": \"TST\",\n \"name\": \"Example space\",\n \"description\": {\n \"plain\": {\n \"value\": \"This is an example space\",\n \"representation\": \"plain\"\n }\n },\n \"metadata\": {}\n}"
152+
},
153+
{
154+
"id": "6f08c5a7-47e5-cf42-5304-aed6b920e99a",
155+
"headers": "Content-Type: application/json\nAuthorization: Basic dGVzdDE6c2JAMTIz\n",
156+
"headerData": [
157+
{
158+
"key": "Content-Type",
159+
"value": "application/json",
160+
"description": "",
161+
"enabled": true
162+
},
163+
{
164+
"key": "Authorization",
165+
"value": "Basic dGVzdDE6c2JAMTIz",
166+
"description": "",
167+
"enabled": true
168+
}
169+
],
170+
"url": "https://192.168.1.119/rest/api/content/",
171+
"queryParams": [],
172+
"pathVariables": {},
173+
"pathVariableData": [],
174+
"preRequestScript": null,
175+
"method": "POST",
176+
"collectionId": "39953387-3711-f272-1ab4-3da1c21b3f0c",
177+
"data": [],
178+
"dataMode": "raw",
179+
"name": "Search Call",
180+
"description": "",
181+
"descriptionFormat": "html",
182+
"time": 1548421958811,
183+
"version": 2,
184+
"responses": [],
185+
"tests": null,
186+
"currentHelper": "normal",
187+
"helperAttributes": {},
188+
"rawModeData": " {\"type\":\"page\",\n \"title\":\"My Test Page\",\n \"space\":{\"key\":\"SB\"},\n \"body\":{\"storage\":{\"value\":\"<p>This is a new page</p>\",\"representation\":\"storage\"}}}"
189+
},
190+
{
191+
"id": "8cd10775-0a75-43e1-fb8f-406c6ed18fd3",
192+
"headers": "Content-Type: application/json\nAuthorization: Basic dGVzdDE6c2JAMTIz\n",
193+
"headerData": [
194+
{
195+
"key": "Content-Type",
196+
"value": "application/json",
197+
"description": "",
198+
"enabled": true
199+
},
200+
{
201+
"key": "Authorization",
202+
"value": "Basic dGVzdDE6c2JAMTIz",
203+
"description": "",
204+
"enabled": true
205+
}
206+
],
207+
"url": "https://192.168.1.119/rest/api/content/search?cql=creator=currentUser()",
208+
"queryParams": [
209+
{
210+
"key": "cql",
211+
"value": "creator=currentUser()",
212+
"equals": true,
213+
"description": "",
214+
"enabled": true
215+
}
216+
],
217+
"pathVariables": {},
218+
"pathVariableData": [],
219+
"preRequestScript": null,
220+
"method": "GET",
221+
"collectionId": "39953387-3711-f272-1ab4-3da1c21b3f0c",
222+
"data": [],
223+
"dataMode": "raw",
224+
"name": "Search Call Advance",
225+
"description": "",
226+
"descriptionFormat": "html",
227+
"time": 1548422216350,
228+
"version": 2,
229+
"responses": [],
230+
"tests": null,
231+
"currentHelper": "normal",
232+
"helperAttributes": {},
233+
"rawModeData": ""
234+
},
235+
{
236+
"id": "b01e8ce2-d8f9-de03-655e-5f7f59b2a25e",
237+
"headers": "Content-Type: application/json\nAuthorization: Basic dGVzdDE6c2JAMTIz\n",
238+
"headerData": [
239+
{
240+
"key": "Content-Type",
241+
"value": "application/json",
242+
"description": "",
243+
"enabled": true
244+
},
245+
{
246+
"key": "Authorization",
247+
"value": "Basic dGVzdDE6c2JAMTIz",
248+
"description": "",
249+
"enabled": true
250+
}
251+
],
252+
"url": "https://192.168.1.119//rest/api/space/TST",
253+
"queryParams": [],
254+
"preRequestScript": null,
255+
"pathVariables": {},
256+
"pathVariableData": [],
257+
"method": "POST",
258+
"data": [],
259+
"dataMode": "raw",
260+
"version": 2,
261+
"tests": null,
262+
"currentHelper": "normal",
263+
"helperAttributes": {},
264+
"time": 1548422553234,
265+
"name": "Update Space",
266+
"description": "",
267+
"collectionId": "39953387-3711-f272-1ab4-3da1c21b3f0c",
268+
"responses": [],
269+
"rawModeData": "{\n \"key\": \"TST\",\n \"name\": \"Example space, SnippetBucket.com\",\n \"description\": {\n \"plain\": {\n \"value\": \"This is an example space\",\n \"representation\": \"plain\"\n }\n },\n \"metadata\": {}\n}"
270+
},
271+
{
272+
"id": "fb6b35e4-4168-0f92-75d6-2a04113b755f",
273+
"headers": "",
274+
"headerData": [],
275+
"url": "",
276+
"queryParams": [],
277+
"pathVariables": {},
278+
"pathVariableData": [],
279+
"preRequestScript": null,
280+
"method": "GET",
281+
"collectionId": "39953387-3711-f272-1ab4-3da1c21b3f0c",
282+
"data": null,
283+
"dataMode": "params",
284+
"name": "Confluence API Status Test",
285+
"description": "",
286+
"descriptionFormat": "html",
287+
"time": 1548416627684,
288+
"version": 2,
289+
"responses": [],
290+
"tests": null,
291+
"currentHelper": "normal",
292+
"helperAttributes": {}
293+
}
294+
]
295+
}

test-rest-call.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import logging, requests, pprint
2+
3+
# Setup logging
4+
logging.basicConfig(level=logging.DEBUG)
5+
6+
base = 'https://<instance>.example.com'
7+
username = 'user'
8+
password = '******'
9+
10+
session = requests.Session()
11+
session.auth = (username, password)
12+
13+
# Get the server info
14+
url = base + '/rest/api/2/serverInfo'
15+
r = session.get(url)
16+
pprint.pprint(r.json())
17+
18+
# Get an issue
19+
url = base + '/rest/api/2/issue/CUA-1'
20+
r = session.get(url)
21+
pprint.pprint(r.json())
22+
23+

test-rest-issue-read.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import requests
2+
import pprint
3+
import logging
4+
from requests.cookies import RequestsCookieJar
5+
6+
logging.basicConfig(level=logging.DEBUG)
7+
8+
9+
class ObliviousCookieJar(RequestsCookieJar):
10+
def set_cookie(self, *args, **kwargs):
11+
"""Simply ignore any request to set a cookie."""
12+
pass
13+
14+
def copy(self):
15+
"""Make sure to return an instance of the correct class on copying."""
16+
return ObliviousCookieJar()
17+
18+
19+
base = 'https://<instance>.atlassian.net'
20+
username = 'user'
21+
password = '******'
22+
23+
session = requests.Session()
24+
session.cookies = ObliviousCookieJar()
25+
session.auth = (username, password)
26+
27+
# Get the server info
28+
url = base + '/rest/api/2/serverInfo'
29+
r = session.get(url)
30+
pprint.pprint(r.json())
31+
32+
# Get an issue
33+
url = base + '/rest/api/2/issue/CUA-1'
34+
r = session.get(url)
35+
pprint.pprint(r.json())

test-rest-serverinfo.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import logging, requests, pprint
2+
3+
# Setup logging
4+
logging.basicConfig(level=logging.DEBUG)
5+
6+
base = 'https://<instance>.atlassian.net'
7+
username = 'user'
8+
password = '******'
9+
10+
session = requests.Session()
11+
session.auth = (username, password)
12+
13+
# Get the server info
14+
url = base + '/rest/api/2/serverInfo'
15+
r = session.get(url)
16+
pprint.pprint(r.json())

0 commit comments

Comments
 (0)