I'm trying to recreate my Zom record patch fucntion with aiohttp.
What i have now:
async def update_zoom_record(id, fields, token):
url = urljoin(settings.GET_MEETING_URL, str(id))
post_headers = {'origin': origin, 'Authorization': token,
'Content-Type': 'application/json'}
body = json.dumps({'topic': fields['subject']})
async with aiohttp.ClientSession() as session:
async with session.patch(url, json=body, headers=post_headers ) as resp:
if resp.status != 204:
raise Exception('Problems with patching zoom meeting data')
And unlike simple resp = requests.get(url, headers=post_headers)
it gives me status 400.
I've compared headers objects of both requests:
async:
headers=<CIMultiDictProxy('Host': 'api.zoom.us', 'origin': 'https://developer.zoom.us',
'Authorization': 'Bearer ...',
'Content-Type': 'application/json', 'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate',
'User-Agent': 'Python/3.8 aiohttp/3.7.3', 'Content-Length': '30')>, real_url=URL('https://api.zoom.us/v2/meetings/876...'))
sync:
headers:{'User-Agent': 'python-requests/2.24.0', 'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*', 'Connection': 'keep-alive', 'origin': 'https://developer.zoom.us',
'Authorization': 'Bearer ...',
'Content-Type': 'application/json', 'Content-Length': '24'}
So, probably Zoom do not want to see 'Host' header, which is strange, but may be.
I cannot find any way to remove thi built-in header. I've tried:
async with aiohttp.ClientSession() as session:
sessiom.headers.clear()
async with session.patch(url, json=body, headers=post_headers ) as resp:
but no luck.
Any ideas?
question from:
https://stackoverflow.com/questions/65841898/how-to-remove-built-in-headers-of-aiohttp-clientsession