OpenNETCF Extensions: Making a REST service call

REST web services are pretty straightforward and really, really common (you used one to read this blog page).  As software gets implemented as services, it’s getting more and more common for us as developers to have to make REST calls programmatically.  Lately I’ve been implementing a lot of services using Padarn on both the device and the PC and then implementing client libraries to access those services.  In doing so, it only made sense to create some infrastructure to make my life a little easier, and so the RestConnector (and DigestRestConnector) was born.

For a simple GET, such as to get the response for this page, the code is trivial:


var connector = new RestConnector(“”);
var response = connector.Get(“/ctacke”);

Other verbs like POST and PUT are nearly as simple.

var response = connector.Post(“/upload”, myData);

For services that require authentication, there’s the DigestRestConnector that behaves the same, except the ctor takes in a UID/PWD pair as well. The classes support the four common verbs I use: GET, PUT, POST and DELETE. Of course since it’s open-source, feel free to extend them as you wish.

The OpenNETCF Extensions library is a collection of extension methods and helper classes that I find useful in a lot of different projects. It’s compatible with the Compact Framework, Tirethe full framework and Windows Phone.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s