Goals
▪Understand REST
▪What
▪Why
▪Get comfortable with ASP.NET Web API
10/8/2013 1
Agenda
▪Quick Demo
▪REST and Why You Should Care
▪Building an API with ASP.NET Web API
10/8/2013 2
What is REST
▪Stands For:
▪REpresentational State Transfer
▪Architectural Style based on HTTP
10/8/2013 3
What is HTTP?
▪Well defined protocol (web browsers, web servers, etc.)
▪Request and Response
▪Stateless
▪Request Contents
▪URL
▪HTTP Verb
▪Header
▪Message Body
10/8/2013 4
What is REST
▪Architectural Style based on HTTP
▪Resources (Things)
▪Verbs (Actions)
▪GET, POST, PUT, DELETE, etc.
▪Response gives a representation of the resource (XML, JSON,
image, etc.)
More Info: http://en.wikipedia.org/wiki/REST
10/8/2013 5
Resources
▪GET http://en.gravatar.
com/userimage/7361283/02c115a8f3967a.jpg
▪GET https://www.diigo.com/user/jfjcn1/webApi
10/8/2013 6
HTTP Verbs
▪GET
▪Gets 0 or more of a resource (thing)
▪POST
▪Creates a resource (hopefully)
▪PUT
▪Updates a resource (hopefully)
▪DELETE
▪Deletes a resource (hopefully)
10/8/2013 7
REST in Action
Actions:
▪ GET
▪ POST
▪ PUT
▪ DELETE
Resources:
▪ http://somedomain.com/users/1
▪ https://otherdomain.com/products
10/8/2013 8
REST Responses
▪Responses come back as an HTTP Status Code + message (maybe)
▪HTTP Status Codes
▪1XX – Request Received and I’m processing it
▪2XX – Request Received and processed it successfully!
▪3XX – Client must do something else to complete the request
▪4XX – Client made an error
▪5XX – Server error
10/8/2013 9
Popular Status Codes
▪200 – Success
▪201 – Created
▪301 – Moved Permanently (AKA “redirect”)
▪404 – Not Found
▪401 – Unauthorized
▪500 – Internal Server Error (AKA “oh crap!”)
10/8/2013 10
On to the codez…
10/8/2013 11
Why REST?
▪Everyone/everything speaks HTTP
▪Web applications are moving to JavaScript + AJAX
▪Lightweight compared to SOAP
▪Caching of resources (server decides)
▪http://en.gravatar.com/userimage/7361283/02c115a8f3967a.jpg
10/8/2013 12
REST is NOT a standard
10/8/2013 13
Thank You!
fernando@TalentRiot.com
http://kaizencto.com
@avfernando
10/8/2013 14

How to build a rest api.pptx