Pass request as content instead of data

data works, but should be used for form data passed as a dict, while
content takes bytes or str
This commit is contained in:
Ivan Habunek 2024-04-23 18:19:59 +02:00
parent 3c0f8a8ece
commit 3fa8bcef73
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D

View File

@ -87,10 +87,10 @@ class GQLError(click.ClickException):
super().__init__(message)
def authenticated_post(url, data=None, json=None, headers={}):
def authenticated_post(url, content=None, json=None, headers={}):
headers["Client-ID"] = CLIENT_ID
response = httpx.post(url, data=data, json=json, headers=headers)
response = httpx.post(url, content=content, json=json, headers=headers)
if response.status_code == 400:
data = response.json()
raise ConsoleError(data["message"])
@ -102,7 +102,7 @@ def authenticated_post(url, data=None, json=None, headers={}):
def gql_post(query: str):
url = "https://gql.twitch.tv/gql"
response = authenticated_post(url, data=query)
response = authenticated_post(url, content=query)
gql_raise_on_error(response)
return response.json()