© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
4 replies
Ice_

❔ Bad request (400) - web api

I am not sure why this is happening because it works splendid with one class and not with another class for whatever reason. The code is basically identical in the controllers (and repositories).
I don't have the code to show you because it's code from a friend of mine earlier today through Zoom.
What we discovered was is that the POST method does not execute in the controller at all. The 400 error message is thrown before it actually connects to the API.
It works through Swagger though, so there's an issue with the httpclient I guess but I can't really seem to pinpoint what the issue is. We are using PostAsJsonAsync in this case.

My question for this whole thread is: Can I somehow print out the details of the "bad request" error code? What part is "bad"?
The error codes gives you a good pointer but when you really can't see what the hell is going wrong, you want the details. So how do I get them? 😅
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Http 400 Bad Request Response [Answered]
C#CC# / help
4y ago
400 bad request on seemingly valid POST
C#CC# / help
6mo ago
❔ Web Request
C#CC# / help
3y ago
✅ Local Post, 400 Bad Request. Can't figure out why?
C#CC# / help
15mo ago