Skip to content

Httpx behaving differently than requests? #3118

Answered by MtkN1
EricPanDev asked this question in Q&A
Discussion options

You must be logged in to vote

This discussion is probably about Discord API parameters.

I'm interested in the Discord API, so I looked into it ... https://discord.com/developers/docs/reference#uploading-files

The JSON message body can optionally be provided using the payload_json parameter.

This solves the problem.

import json
...
payload_json = {"payload_json": json.dumps(payload)}
r = httpx.post(f"https://discord.com/api/v9/channels/{channel_id}/messages", data=payload_json, headers=header, files=files)


I don't know if the form data encoding of requests is correct 🤔

Replies: 7 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@tomchristie
Comment options

Comment options

You must be logged in to vote
1 reply
@tomchristie
Comment options

Answer selected by EricPanDev
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #3117 on February 26, 2024 14:11.