Rest(ish) Toolkit for Windows 8 / 8.1

When I first started building apps on Windows 8, I wasn’t doing it that seriously, as I built more and more apps, it started to make sense that given their content, perhaps some of them talk to each other or back to a central server.

Having used RestSharp before I was pretty keen to just drop that in and start firing off requests. It was fairly painful when I realised that it doesn’t support Windows 8 and I’d be left to hacking together my own.

After a several months if not a year of tinkering and updating between dozens of projects, I’ve finally produced a rest helper that works for me, but might also hopefully work for you. Keep in mind it’s still a bit hacky, but better than nothing.

This helper is fairly primitive, but it does the basic things like handling basic authentication and allows you to send off and receive json objects. More than enough for most apps.

It can then be used like this

await ApiToolkit.Get<ObservableCollection<MyItem>>("MyEnd/Point");

and

await ApiToolkit.Post(myObject, "myEnd/Point");

My authenticate method fires off a GET (should be a POST, don’t get me started…) to another endpoint to let me know which apps are connecting to the server most frequently (this lets me know which apps I should be updating!) You might want to tweak that a little depending on what your API looks like.

Always open to feedback, suggestions or pull requests.

https://gist.github.com/LucasMoffitt/8abf13630558e42faecb.js

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s