Bug: query params doesn't work? #2816
-
Descriptioni am trying the litestar library for the api development. i found there are some stranges doc: https://docs.litestar.dev/latest/usage/routing/parameters.html#query-parameters from litestar import Litestar, get
@get("/", sync_to_thread=False)
def index(param: str) -> dict[str, str]:
return {"param": param}
app = Litestar(route_handlers=[index]) > curl http://127.0.0.1:8000/?param=foo
{"param":"foo"}
> curl http://127.0.0.1:8000/?param=bar
{"param":"bar"} but the terminal show me when i follow the instruction zsh: no matches found: http://localhost:8000?param=uiyhkjh when i remove the query param, it showed {"status_code":400,"detail":"Missing required query parameter 'param' for url http://localhost:8000/"}% i have no idea on the issue, i just simply follow the guidelines, without any modification URL to code causing the issueNo response MCVE# Your MCVE code here Steps to reproduce1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error Screenshots"![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)" LogsNo response Litestar VersionVersion(major=2, minor=4, patch=1, release_level='final', serial=0) Platform
Note While we are open for sponsoring on GitHub Sponsors and Check out all issues funded or available for funding on our Polar.sh Litestar dashboard
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
It's not clear what you are doing here. Where does it show that? What instruction are you following? The |
Beta Was this translation helpful? Give feedback.
The error message is coming from zsh, not Litestar. You need to either escape the
?
or surround the whole string in quotes.curl "http://localhost:8000?param=uiyhkjh"