A day after, I now found the cause for this error. The following reasons caused this error to happen:
- There was a typo in the PUT call, so the Web API method wasn't called. After fixing that, the following two issues had to be fixed:
- It wasn't sufficient to prefix the Web API methods with the method and omit the corresponding attributes (
[HttpPut]
, [HttpDelete]
). So, these attributes had to be applied (this is particular to ASP.NET Core).
- It wasn't sufficient to provide the above attributes to the methods. It was required to provide the methods' address (and query string, resp.) parameters for these attributes (
[HttpPut("{id}")]
, [HttpDelete("{id}")]
), too. (This is particular to ASP.NET Core.)
See ASP.NET Core Web API: Routing by method name? .
I believe "**405 Method not allowed**" to be *quite* an inappropriate error message. It doesn't reflect any of the above three reasons and is very confusing.
I, moreover, believe that "400 Bad Request", "404 Not Found", or - rather - "501 Not Implemented" would have been rather more appropriate HTTP return states.
I created a GitHub issue on this:
["405: Method not allowed" = Misleading error message → Replace with better HTTP status code][1]