I've been trying to follow the instructions on Zoom's website, but I'm getting a 400 error back each time I try to send the captions.
{"timestamp":1594640701018,"status":400,"error":"Bad Request","message":"No message available","path":"/closedcaption"}
The documentation says that a 400 comes back when the meeting hasn't started yet, but in my test scenario I have two devices connected to the meeting and I'm copying the Closed Caption API Token from the host before giving it to my test program. As far as I can tell, that's a started meeting, so there must be something else up. I've tried sending requests multiple times, but still get 400 errors back.
I'm using Python 3, and I've tried both urllib.request
and http.client
, but to no avail. What am I missing?
import urllib.request
import http.client
third_party_api_token = input('Third Party CC Token: ')
domain = third_party_api_token.split('/')[2]
if 'https://' in third_party_api_token:
domain = domain + ':443'
else:
domain = domain + ':80'
seq = 1
while True:
input('Press Enter to continue')
formatted_url = '{}&lang=en-US&seq={}'.format(zoom_cc_url, seq)
# formatted_text = 'Hello World\n'.encode('utf-8')
formatted_text = 'Hello World\n'
headers = {'Content-Type':'text/plain'}
print(domain)
print(formatted_url)
try:
# r = urllib.request.Request(formatted_url, data=formatted_text, headers=headers, method='POST')
# with urllib.request.urlopen(r) as response:
# print(response.read().decode('utf-8'))
conn = http.client.HTTPSConnection(domain)
conn.request("POST", formatted_url.replace(domain, ''), body=formatted_text, headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
except Exception as e:
print(e)
seq += 1
Left an old variable name in the code, works fine when I remove it. For reference, the below code works: