MVC App's Post request not reaching
First off, yes I already asked this last friday but couldn't follow trough due to not having the source code for the weekend.
Either way, here's my problem: I have an MVC Web Api in .NET 8.0, all Get requests from all controllers work as intended, but for Post requests on the other hand, they all return an HTTP Error 405 (Method not Allowed). Here is my initialization class and one of my Post method (they are all basiaclly structured the same) (Also, all the Cors stuff are things I already tried with no avail)
Initialization Class:
Controller Example:
6 Replies
You mean a
POST: /api/Regions/Post
request results in 405?
I wonder if the issue might be with that CreatedAtAction
...? You pass an object with an id
to it, yet the GetRegion
method neither takes nor returns it
As a side note,
can just be
Yes I changed that and that resolved the error 405, but now I have some other problems: I am getting an error 415 if i use [FromBody], but [FromForm] returns an error 400, problem is I have no clue how to make a post request with [FromForm]
What's 415 remind me?
Unsupported Media Type
This is my request
Actually, it doesn't seem to be reaching at all, I have a breakpoint in my API and it is never hit, but when I try to reach the call straight from my browser, then it return 415 (which I'm guessing is normal since I don't send any body when trying this way)
Update: Whatever I did (I just reverted to my old code) now works, only problem is that I need to desrialize NetTopologySuite json to object in MVC.
Any particular reason for this whole song and dance instead of just
?
Far as unsupported media type, it happens when you bind from body but send a form, or bind from form but send JSON
Or any other pair of incompatible media types
Tbh, I totally forgot that was a thing...