Я пытался:
async def createPoll():
question = "Is this thing on?"
options = ["Yes", "No", "Maybe"]
try:
async with aiohttp.ClientSession() as session:
print('HERE')
async with session.post(
"https://www.strawpoll.me/api/v2/polls",
json={
"title": question,
"options": options,
"multi": "false"
},
headers={"Content-Type": "application/json"}
) as response:
print(response)
json = await response.json()
strawpoll_id = json["id"]
print(f"https://strawpoll.me/{strawpoll_id}")
except Exception as e:
print(e)
Единственное, что я изменил, было Content Type
на Content-Type
и вывод, который я получил:
<ClientResponse(https://www.strawpoll.me/api/v2/polls) [200 OK]>
<CIMultiDictProxy('Access-Control-Allow-Headers': 'X-Requested-With', 'Access-Control-Allow-Origin': '*', 'Cache-Control': 'private, no-cache="set-cookie"', 'Content-Type': 'application/json; charset=utf-8', 'Server': 'Microsoft-IIS/10.0', 'Set-Cookie': 'AWSELB=193D972F16169235196B775BF1B5BFF2D266A3E7F134840A661FD488EC125877D4193B20C4FCDBDB753E1C0E576E03398F3B7AAE5AAC9D70BFE31DB4F45EABEEB6F46BFBEE;PATH=/;MAX-AGE=3600', 'Set-Cookie': 'AWSELBCORS=193D972F16169235196B775BF1B5BFF2D266A3E7F134840A661FD488EC125877D4193B20C4FCDBDB753E1C0E576E03398F3B7AAE5AAC9D70BFE31DB4F45EABEEB6F46BFBEE;PATH=/;MAX-AGE=3600;SECURE;SAMESITE=None', 'X-AspNet-Version': '4.0.30319', 'X-AspNetMvc-Version': '5.2', 'X-Frame-Options': 'DENY', 'X-UA-Compatible': 'IE=edge,chrome=1', 'Content-Length': '140', 'Accept-Ranges': 'bytes', 'Date': 'Fri, 06 Mar 2020 07:47:42 GMT', 'Via': '1.1 varnish', 'Connection': 'keep-alive', 'X-Served-By': 'cache-hhn4027-HHN', 'X-Cache': 'MISS', 'X-Cache-Hits': '0', 'X-Timer': 'S1583480862.671417,VS0,VE458', 'Set-Cookie': 'Geo={%22region%22:%22HE%22%2C%22country%22:%22DE%22%2C%22continent%22:%22EU%22}; path=/; domain=.strawpoll.me; SameSite=None; Secure;', 'Strict-Transport-Security': 'max-age=300')>