Skip to content
Todd Justin York edited this page Feb 7, 2017 · 10 revisions

You can make a HttpClient like this.

var http = new HttpClient();

The empty constructor means that you will have to provide a url for each and every call (Get, Post, ...)

Or like this

var http = new HttpClient("http://localhost");

Here we instantiated the client with a baseuri. For all the calls you make with this client the baseuri will be prefixed to your uri.

So this.

var http = new HttpClient("http://localhost");
var result = http.Get("/trees");

is actually the same as writing.

var http = new HttpClient("http://localhost");
var result = http.Get("http://localhost/trees");

The httpclient object contains the Request and Response object. You can set properties on those objects to control the request and response.

The httpclient also contains the following http verbs which you can use.

Clone this wiki locally