Can I pass body and multipart file into `RedirectResponse` in `post` method?
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
from fastapi import FastAPI
app = FastAPI()
@app.post("/")
def read_root(image_url: Optional[str] = Query('', alias="image_url"), file: UploadFile = File(Required, alias="file")):
return RedirectResponse("/another")
@app.post("/another")
def read_another_root(image_url: Optional[str] = Query('', alias="image_url"), file: UploadFile = File(Required, alias="file")):
return {"Hello": "World"}
Description
When the server is requested at /
in post
method, I want to redirect the /another
in post
method with same body and multipart file.
How can I pass the original body and multipart file into the redirection endpoint?
Operating System
Linux
Operating System Details
No response
FastAPI Version
0.65.2
Python Version
3.8.5
Additional Context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
RequestBody and Multipart on Spring Boot - Perficient Blogs
Step 7: Upload the Multipart file and POJO in Postman. Now, Test the response using Postman by adding the body parameters and values...
Read more >How to redirect multipart POST request to a second server in ...
I am trying to create separate frontend/backend services. Frontend only handles UI related processing, while backend will actually do some ...
Read more >Exploring the HTTP request syntax | PhpStorm Documentation
To read the request body from a file, type the < symbol followed by the path to the file. // The request body...
Read more >Custom Response - HTML, Stream, File, others - FastAPI
But if you are certain that the content that you are returning is serializable with JSON, you can pass it directly to the...
Read more >Documentation - A lightweight Java and Kotlin web framework
Before-handlers are matched before every request (including static files). ... You can add a GET handler to server data to a client, or...
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
What is the usecase? You could just add multiple paths for the same endpoint
I don’t think it is supported in the same way a GET is as the user would need to confirm the redirection
User (Data) -> Server 1 Server 1 (Redirect to Server 2) -> User User - who the heck is server 2… 😃
Since you are not redirecting to another server, you can just call the function directly