I have a default mvc web api instance built from the Visual Studio 2012 template. It has the following routes and post method in the default ValuesController - the MVC site
Try the following code:
class Program {
static void Main(string[] args) {
HttpClient client = new HttpClient();
var content = new StringContent("=Here is my input string");
content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
client.PostAsync("http://localhost:2451/api/values", content)
.ContinueWith(task => {
var response = task.Result;
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
});
Console.ReadLine();
}
}
Have a look at the "Sending Simple Types" section of this blog post: http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-1