Cannot pass URL Encoded string containing '/' as path parameter to GET endpoint
See original GitHub issueFirst Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn’t find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google “How to X in FastAPI” and didn’t find any information.
- I already read and followed all the tutorial in the docs and didn’t find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- I commit to help with one of those options 👆
Example Code
@app.get('/images/thumbnail/{filename}',
response_description="Returns a thumbnail image",
response_class="StreamingResponse",
responses= {200: {"description": "an image", "content": {"image/jpeg": {}}}})
async def thumbnail_image (filename: str):
Description
I have an endpoint that needs to take a filename (or path to filename) parameter string that could be something like “myimage.jpg” (which works) or something like “path/to/myimage.jpg” (which doesn’t work)
http://localhost:8000/images/thumbnail/landscapes%2FIMG_1462.jpeg does not enter the endpoint above and gets back a 404
I’ve tried removing the {filename} path param to form a regular query parameter but it doesn’t help. I am using the Javascript encodeURIComponent to create the string that is being sent as the parameter.
Operating System
macOS
Operating System Details
No response
FastAPI Version
0.70.1
Python Version
3.8
Additional Context
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7
Top Results From Across the Web
How to pass URL as a path parameter to a FastAPI route?
Option 1. You can simply use the path convertor to capture arbitrary paths. As per Starlette documentation, path returns the rest of the ......
Read more >Pass API Gateway REST API parameters to a Lambda ...
I need my Amazon API Gateway REST API to pass query string parameters to a backend AWS Lambda function and an HTTP endpoint....
Read more >Azure API Management transformation policies | Microsoft Learn
Reference for the transformation policies available for use in Azure API Management. Provides policy usage, settings, and examples.
Read more >Describing Parameters - Swagger
A URL can have several path parameters, each denoted with curly braces { } . ... (strings, numbers, booleans) or arrays of primitives...
Read more >any way to not use URL encoding? - OutSystems
Dynamic routes with special characters - any way to not use URL ... query string (also supported) we have to send these parameters...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Reading about it again, it looks like
starlette
supports apath
convertor.The following should do what you want:
Hi, my workaround to this issue was passing a base64 encoded variable in the querystring. My FastAPI endpoint looks like this: