aboutsummaryrefslogtreecommitdiffhomepage
path: root/support
diff options
context:
space:
mode:
authorMatthieu De Beule <matthieu.de@beule.be>2019-11-12 14:46:43 +0100
committerMatthieu De Beule <matthieu.de@beule.be>2019-11-12 14:46:43 +0100
commitf6d51cfe2aa4c1a1f48dab665cc3bebee178e383 (patch)
tree3aa7d191b8f92ff93281b9994925c19a686e74ff /support
parente8e09e27ff49e694638b7f24dbb97e8de25ac416 (diff)
downloadPeerTube-f6d51cfe2aa4c1a1f48dab665cc3bebee178e383.tar.gz
PeerTube-f6d51cfe2aa4c1a1f48dab665cc3bebee178e383.tar.zst
PeerTube-f6d51cfe2aa4c1a1f48dab665cc3bebee178e383.zip
Fix Ruby and Python REST API examples
The previous examples where wrong, since they used a POST request. I used the requests library for Python, since that is what most people would want to use. I removed the http.verify_mode in the Ruby example since I don't think it is good practice to tell people to not verify HTTPS requests
Diffstat (limited to 'support')
-rw-r--r--support/doc/api/openapi.yaml30
1 files changed, 10 insertions, 20 deletions
diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml
index a13627a78..032d798fc 100644
--- a/support/doc/api/openapi.yaml
+++ b/support/doc/api/openapi.yaml
@@ -160,35 +160,25 @@ paths:
160 http -b GET https://peertube2.cpy.re/api/v1/accounts/{name}/videos 160 http -b GET https://peertube2.cpy.re/api/v1/accounts/{name}/videos
161 - lang: Ruby 161 - lang: Ruby
162 source: | 162 source: |
163 require 'uri'
164 require 'net/http' 163 require 'net/http'
164 require 'json'
165 165
166 url = URI("https://peertube2.cpy.re/api/v1/accounts/{name}/videos") 166 uri = URI.parse("https://peertube2.cpy.re/api/v1/accounts/{name}/videos")
167 167
168 http = Net::HTTP.new(url.host, url.port) 168 http = Net::HTTP.new(uri.host, uri.port)
169 http.use_ssl = true 169 http.use_ssl = true
170 http.verify_mode = OpenSSL::SSL::VERIFY_NONE
171 170
172 request = Net::HTTP::Post.new(url) 171 response = http.get(uri.request_uri)
173 request["content-type"] = 'application/json' 172
174 response = http.request(request) 173 puts JSON.parse(response.read_body)
175 puts response.read_body
176 - lang: Python 174 - lang: Python
177 source: | 175 source: |
178 import http.client 176 import requests
179
180 conn = http.client.HTTPSConnection("https://peertube2.cpy.re/api/v1")
181
182 headers = {
183 'content-type': "application/json"
184 }
185
186 conn.request("POST", "/accounts/{name}/videos", None, headers)
187 177
188 res = conn.getresponse() 178 r = requests.get("https://peertube2.cpy.re/api/v1//accounts/{name}/videos")
189 data = res.read() 179 json = r.json()
190 180
191 print(data.decode("utf-8")) 181 print(json)
192 /accounts: 182 /accounts:
193 get: 183 get:
194 tags: 184 tags: