In June I published a blog post about creating a class for easily consuming data from RESTful web services (http://geek-goddess-bonnie.blogspot.com/2014/06/proxy-class-for-consuming-restful.html). Since then, I've had the need to use credentials to access a REST service, so my class has had to change a bit. Not much, but I thought it was enough to warrant a new blog post, so here it is. Basically all I did was add UserName and Password properties, plus another constructor like this:
And the GetJSON() method was modified slightly to add the credentials to the WebClient:
And the rest is the same as in my earlier post. Pretty easy, eh?