Unsupported Media Type error when posting to Web API

You should set the media type when creating StringContent

new StringContent(json, Encoding.UTF32, "application/json");

I found this question while working on a quick and dirty reverse proxy. I needed form data and not JSON.

This did the trick for me.

string formData = "Data=SomeQueryString&Foo=Bar";
var result = webClient.PostAsync("http://XXX/api/XXX", 
        new StringContent(formData, Encoding.UTF8, "application/x-www-form-urlencoded")).Result;