Click here to Skip to main content
11,704,107 members (48,693 online)
Click here to Skip to main content

How to Retrieve a Scalar Value from a REST method

, 16 Jan 2014 CPOL 3.5K 6
Rate this:
Please Sign up or sign in to vote.
Retrieve scalar vals from REST methods

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)

Hats off to Larry, I mean Jon Skeet, for turning me on to WebClient.DownloadString()

As the Frenchmen say, voilà!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

B. Clay Shannon
Founder "Across Time & Space"
United States United States
Ideaman and Coder at Across Time & Space, creator of "Mark Twain Central" at

Peripatetic and picaresque, I have lived in eight states; specifically, besides my native California (where I was born and where I now again reside) in chronological order: New York, Montana, Alaska, Oklahoma, Wisconsin, Idaho, and Missouri.

I am also a writer of both fiction (for which I use a nom de plume, "Blackbird Crow Raven", as a nod to my Native American heritage - I am "½ Cowboy, ½ Indian") and nonfiction:

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150819.1 | Last Updated 16 Jan 2014
Article Copyright 2014 by B. Clay Shannon
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid