14.01.2015 Views

Eric lippert - Amazon Web Services

Eric lippert - Amazon Web Services

Eric lippert - Amazon Web Services

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Once the post completes, we switch to the Inspectors and select<br />

‘TextView’. We can see the Text returned by our <strong>Web</strong> API service.<br />

It detected the Content-Type request and sent us back a ‘text/<br />

calendar’. To get the actual file, click on the ellipsis button to the<br />

right of ‘View in Notepad’ button, at the bottom of the screen.<br />

our TimeCard data into a VCalendar that can be downloaded and<br />

imported into Outlook!<br />

To Wrap up<br />

Well, with the Media Type Formatter demo, we bring this article<br />

to a close. Today we saw how to build web services using<br />

ASP.NET <strong>Web</strong>API and access them over HTTP using AJAX. We sent<br />

our service request via browser as well as via a HTTP tool called<br />

Fiddler. We got back response as JSON and we built a custom<br />

formatter to get data as a VCalendar.<br />

On clicking the ellipsis, we get the following (on Windows 8).<br />

You will see all apps that are registered to deal with ICS files in<br />

that list<br />

Now that we have our service in place, we can very easily build<br />

clients on any platform that can communicate over HTTP (which<br />

is essentially all platforms). So we could have Windows 8 App<br />

or a Windows Phone App or an iOS app talk to the same service<br />

and get back this same data.<br />

We covered two key areas of <strong>Web</strong> API. We have not looked at<br />

Authentication and Authorization among other things. Those we<br />

leave for another day<br />

Download the entire source code from Github at<br />

bit.ly/dncm6-wapicf<br />

On selecting Outlook, I get the Calendar item imported into my<br />

calendar. Check the screenshot below!<br />

Isn’t that awesomesauce<br />

Suprotim Agarwal, ASP.NET Architecture MVP,<br />

is an author and the founder of popular .NET<br />

websites like dotnetcurry.com, devcurry.com<br />

and the DNC Magazine. You can follow him on<br />

twitter @suprotimagarwal<br />

We just built a Custom Media Type Formatter that can format<br />

DNcmagazine www.dotnetcurry.com | 71

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!