Skip to content

Commit 11292a7

Browse files
authored
docs: fix outdated and incorrectly styled REST API code examples (#896)
1 parent 26f98e3 commit 11292a7

13 files changed

+2110
-1617
lines changed

_includes/rest/analytics.md

+41-33
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,19 @@ curl -X POST \
3434
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>events/AppOpened
3535
</code></pre>
3636
<pre><code class="python">
37-
import json,httplib
38-
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
37+
import http.client
38+
import json
39+
40+
41+
connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
3942
connection.connect()
40-
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>events/AppOpened', json.dumps({
41-
}), {
42-
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
43-
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
44-
"Content-Type": "application/json"
45-
})
43+
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>events/AppOpened', '', {
44+
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
45+
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
46+
"Content-Type": "application/json"
47+
})
4648
result = json.loads(connection.getresponse().read())
47-
print result
49+
print(result)
4850
</code></pre>
4951
</div>
5052

@@ -73,22 +75,25 @@ curl -X POST \
7375
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>events/Search
7476
</code></pre>
7577
<pre><code class="python">
76-
import json,httplib
77-
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
78+
import http.client
79+
import json
80+
81+
82+
connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
7883
connection.connect()
7984
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>events/Search', json.dumps({
80-
"dimensions": {
81-
"priceRange": "1000-1500",
82-
"source": "craigslist",
83-
"dayType": "weekday"
84-
}
85-
}), {
86-
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
87-
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
88-
"Content-Type": "application/json"
89-
})
85+
"dimensions": {
86+
"priceRange": "1000-1500",
87+
"source": "craigslist",
88+
"dayType": "weekday"
89+
}
90+
}), {
91+
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
92+
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
93+
"Content-Type": "application/json"
94+
})
9095
result = json.loads(connection.getresponse().read())
91-
print result
96+
print(result)
9297
</code></pre>
9398
</div>
9499

@@ -108,20 +113,23 @@ curl -X POST \
108113
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>events/Error
109114
</code></pre>
110115
<pre><code class="python">
111-
import json,httplib
112-
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
116+
import http.client
117+
import json
118+
119+
120+
connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
113121
connection.connect()
114122
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>events/Error', json.dumps({
115-
"dimensions": {
116-
"code": "404"
117-
}
118-
}), {
119-
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
120-
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
121-
"Content-Type": "application/json"
122-
})
123+
"dimensions": {
124+
"code": "404"
125+
}
126+
}), {
127+
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
128+
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
129+
"Content-Type": "application/json"
130+
})
123131
result = json.loads(connection.getresponse().read())
124-
print result
132+
print(result)
125133
</code></pre>
126134
</div>
127135

_includes/rest/cloud-code.md

+23-18
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@ curl -X POST \
1515
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>functions/hello
1616
</code></pre>
1717
<pre><code class="python">
18-
import json,httplib
19-
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
18+
import http.client
19+
import json
20+
21+
22+
connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
2023
connection.connect()
21-
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>functions/hello', json.dumps({
22-
}), {
23-
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
24-
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
25-
"Content-Type": "application/json"
26-
})
24+
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>functions/hello', '', {
25+
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
26+
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
27+
"Content-Type": "application/json"
28+
})
2729
result = json.loads(connection.getresponse().read())
28-
print result
30+
print(result)
2931
</code></pre>
3032
</div>
3133

@@ -47,17 +49,20 @@ curl -X POST \
4749
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>jobs/userMigration
4850
</code></pre>
4951
<pre><code class="python">
50-
import json,httplib
51-
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
52+
import http.client
53+
import json
54+
55+
56+
connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
5257
connection.connect()
5358
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>jobs/userMigration', json.dumps({
54-
"plan": "paid"
55-
}), {
56-
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
57-
"X-Parse-Master-Key": "<span class="custom-parse-server-masterkey">${MASTER_KEY}</span>",
58-
"Content-Type": "application/json"
59-
})
59+
"plan": "paid"
60+
}), {
61+
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
62+
"X-Parse-Master-Key": "<span class="custom-parse-server-masterkey">${MASTER_KEY}</span>",
63+
"Content-Type": "application/json"
64+
})
6065
result = json.loads(connection.getresponse().read())
61-
print result
66+
print(result)
6267
</code></pre>
6368
</div>

_includes/rest/config.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@ curl -X GET \
1414
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>config
1515
</code></pre>
1616
<pre><code class="python">
17-
import json,httplib
18-
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
17+
import http.client
18+
import json
19+
20+
21+
connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
1922
connection.connect()
2023
connection.request('GET', '<span class="custom-parse-server-mount">/parse/</span>config', '', {
21-
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
22-
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>"
23-
})
24+
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
25+
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>"
26+
})
2427
result = json.loads(connection.getresponse().read())
25-
print result
28+
print(result)
2629
</code></pre>
2730
</div>
2831

_includes/rest/files.md

+46-34
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ curl -X POST \
1414
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>files/hello.txt
1515
</code></pre>
1616
<pre><code class="python">
17-
import json,httplib
18-
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
17+
import http.client
18+
import json
19+
20+
21+
connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
1922
connection.connect()
2023
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>files/hello.txt', 'Hello, World!', {
21-
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
22-
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
23-
"Content-Type": "text/plain"
24-
})
24+
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
25+
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
26+
"Content-Type": "text/plain"
27+
})
2528
result = json.loads(connection.getresponse().read())
26-
print result
29+
print(result)
2730
</code></pre>
2831
</div>
2932

@@ -55,16 +58,19 @@ curl -X POST \
5558
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>files/pic.jpg
5659
</code></pre>
5760
<pre><code class="python">
58-
import json,httplib
59-
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
61+
import http.client
62+
import json
63+
64+
65+
connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
6066
connection.connect()
6167
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>files/pic.jpg', open('myPicture.jpg', 'rb').read(), {
62-
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
63-
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
64-
"Content-Type": "image/jpeg"
65-
})
68+
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
69+
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
70+
"Content-Type": "image/jpeg"
71+
})
6672
result = json.loads(connection.getresponse().read())
67-
print result
73+
print(result)
6874
</code></pre>
6975
</div>
7076

@@ -89,23 +95,26 @@ curl -X POST \
8995
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>classes/PlayerProfile
9096
</code></pre>
9197
<pre><code class="python">
92-
import json,httplib
93-
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
98+
import http.client
99+
import json
100+
101+
102+
connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
94103
connection.connect()
95104
connection.request('POST', '<span class="custom-parse-server-mount">/parse/</span>classes/PlayerProfile', json.dumps({
96-
"name": "Andrew",
97-
"picture": {
98-
"name": "...profile.png",
99-
"url:": "...profile.png",
100-
"__type": "File"
101-
}
102-
}), {
103-
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
104-
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
105-
"Content-Type": "application/json"
106-
})
105+
"name": "Andrew",
106+
"picture": {
107+
"name": "...profile.png",
108+
"url:": "...profile.png",
109+
"__type": "File"
110+
}
111+
}), {
112+
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
113+
"X-Parse-REST-API-Key": "<span class="custom-parse-server-restapikey">${REST_API_KEY}</span>",
114+
"Content-Type": "application/json"
115+
})
107116
result = json.loads(connection.getresponse().read())
108-
print result
117+
print(result)
109118
</code></pre>
110119
</div>
111120

@@ -124,15 +133,18 @@ curl -X DELETE \
124133
<span class="custom-parse-server-protocol">https</span>://<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span><span class="custom-parse-server-mount">/parse/</span>files/...profile.png
125134
</code></pre>
126135
<pre><code class="python">
127-
import json,httplib
128-
connection = httplib.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
136+
import http.client
137+
import json
138+
139+
140+
connection = http.client.HTTPSConnection('<span class="custom-parse-server-url">YOUR.PARSE-SERVER.HERE</span>', 443)
129141
connection.connect()
130142
connection.request('DELETE', '<span class="custom-parse-server-mount">/parse/</span>files/...profile.png', '', {
131-
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
132-
"X-Parse-Master-Key": "<span class="custom-parse-server-masterkey">${MASTER_KEY}</span>"
133-
})
143+
"X-Parse-Application-Id": "<span class="custom-parse-server-appid">${APPLICATION_ID}</span>",
144+
"X-Parse-Master-Key": "<span class="custom-parse-server-masterkey">${MASTER_KEY}</span>"
145+
})
134146
result = json.loads(connection.getresponse().read())
135-
print result
147+
print(result)
136148
</code></pre>
137149
</div>
138150

0 commit comments

Comments
 (0)