Easy as Eating Pie and Much Faster
If you are just retrieving a scalar (single) value from a REST method (as opposed to an array of json elements or so), it is easy as eating huckleberry pie to call the method and consume the value it returns. How easy? Czech it out:
private string GetScalarVal(string uri)
{
var client = new WebClient();
return client.DownloadString(uri);
}
Now you can call this method as many times as there are methods of that ilk like so:
private void buttonYourLip_Click(object sender, EventArgs e)
{
MessageBox.Show(GetScalarVal("http://localhost:28642/api/duckbilledPlatypi/Count"));
}
Hats off to Larry, I mean Jon Skeet, for turning me on to WebClient.DownloadString()
As the Frenchmen say, voilĂ !