-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
the data paramater in httpx.post and httpx.client.post behave differently than requests.post
Example with discord's API:
This will not work
import httpx
header = {
'Authorization': "Bot token",
}
files = {
"file": ("hi.png", open("./image.png", 'rb'), "image/png")
}
payload = {
"content": "pls work",
"allowed_mentions": {
"parse": []
}
}
channel_id = "1079501847720640682"
r = httpx.post(f"https://discord.com/api/v9/channels/{channel_id}/messages", data=payload, headers=header, files=files)
print(r.status_code)
print(r.text)However with requests, this will work fine
import requests
header = {
'Authorization': "Bot token",
}
files = {
"file": ("hi.png", open("./image.png", 'rb'), "image/png")
}
payload = {
"content": "pls work",
"allowed_mentions": {
"parse": []
}
}
channel_id = "1079501847720640682"
r = requests.post(f"https://discord.com/api/v9/channels/{channel_id}/messages", data=payload, headers=header, files=files)
print(r.status_code)
print(r.text)I am unsure if this is a bug or if I need to pass these arguments differently in httpx
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels