Posting PlainText to Asp WebApi
Recently I have been writing a WebApi project which needs to accept plaintext via the body of a PUT request, and did the logical thing of using the FromBodyAttribute public HttpStatusCode PutKv([FromBody]string content, string keyGreedy) { return HttpStatusCode.OK; } Which didn’t work, with the useful error message of “Unsupported media type.” It turns out that to bind a value type with the FromBody attribute, you have to prefix the body of your request with an =....