Skip to content

httpx, unlike requests, sends null query parameters #2704

Closed Answered by karpetrosyan
podj asked this question in Potential Issue
Discussion options

You must be logged in to vote

FastAPI can accept null as a query parameter value for example

server.py

from fastapi import FastAPI
app = FastAPI()

@app.get('/')
def root(a: str):
        print(f'a={a!r}')

curl

curl "http://127.0.0.1:8000/?a="

server stdout

INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [6589] using StatReload
INFO:     Started server process [6591]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
a=''
INFO:     127.0.0.1:43768 - "GET /?a= HTTP/1.1" 200 OK

If a value doesn't matter or is just blank, the server may use null values, which are valid.
Also see #2712

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@podj
Comment options

@zanieb
Comment options

@tomchristie
Comment options

@podj
Comment options

Answer selected by karpetrosyan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants