HTTPException always returns 200 [QUESTION]
See original GitHub issueMaybe I am missing something as usual as i understand
raise HTTPException(
status_code=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE,
detail="File is not excel",
headers={"X-Error": "There goes my error"},
)
should return status code of 415, but I just always get 200, if line is changed to
return Response(status_code=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE, content="File is not excel",)
voula I get a 415 response code, so I am a bit lost here. Maybe you can explain me, where is my mistake?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
StatusCode in IHttpModule is always 200? - Stack Overflow
I have an custom IHttpModule that handels all available events and logs the HttpContext.Current.Response.StatusCode to a file. My web.config ...
Read more >Handling Exceptions Returned from the Web API
When you return an OK from your method, a 200 HTTP status code is returned, which signifies that no error has occurred.
Read more >HTTP Status Codes: All 63 explained - including FAQ & Video
If all of your content returns a 200 OK status code you can rest assured that your website is working and is properly...
Read more >Guide to Spring Boot REST API Error Handling - Toptal
If our service calls this method and returns directly to the controller, we'll get an HTTP code 200 (OK) even if the resource...
Read more >How to make MVC action return a http error when validation ...
As I have been reading about this, ASP.Net MVC ignores the Status Code just specified (ex: 401) and always return 200. Can I...
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
got it, you need to use
exception_handler
so using this example is useless?
Hello, well I think as 99% it happens to me me, it was user error, Maybe I forgot to import something or imported a wrong module On Tuesday, October 18, 2022 at 12:29:39 PM GMT+3, Saeed Esmaili @.***> wrote:
@galvakojis I didn’t get how you fixed this issue. I’m having the same issue, and couldn’t find anything about exception_handler in the docs. @app.get(“/ping”) async def pong(request: Request): return HTTPException(status_code=400, detail=“oops”) curl returns:
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>