To my surprise, I can't do anything nearly as simple as this, from what I can tell, in the .NET BCL:
byte[] response = Http.Post
(
url: "http://dork.com/service",
contentType: "application/x-www-form-urlencoded",
contentLength: 32,
content: "home=Cosby&favorite+flavor=flies"
);
This hypothetical code above makes an HTTP POST, with data, and returns the response from a Post
method on a static class Http
.
Since we're left without something this easy, what's the next best solution?
How do I send an HTTP POST with data AND get the response's content?