Skip to content

Raw bytes as query parameter #7886

Discussion options

You must be logged in to vote

There's a few issues to be aware of here:

  1. Yes, this is expected behavior in the sense that you are actually sending "b'\\x80\\x03cnumpy\\nsubtract\\nq\\x00.'" to the server, so FastAPI will treat the received value as the result of converting that string into bytes, as you are seeing.

    If you want to receive the original bytes, you need to make the request to your server with the actual bytes in your query parameter (url-encoded), not the stringified version that you are currently sending. (I'm not 100% sure whether query parameters are allowed to have arbitrary (url-encoded) bytes, though.)

  2. In general, you probably don't want to put arbitrary bytes in the query string; typically data …

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by doctorperceptron
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem question-migrate
4 participants
Converted from issue

This discussion was converted from issue #838 on February 28, 2023 11:11.