SlideShare a Scribd company logo
1 of 21
CONSUMING REST IN
.NET
By Aaron Stannard
http://www.aaronstannard.com/
@Aaronontheweb
Microsoft - Startup Developer Evangelist
Table of Contents
• REST 101
• Background of REST
• Consuming RESTful APIs
• RESTful Principles
• Security
• Transport Security
• Authentication
• Authorization
• Anti-Patterns
• REST in .NET
• RestSharp
• Hammock REST
REST is Everywhere
REST
•Representational
•State
•Transfer
REST at a Glance
•REST is not a standard
•It's an architecture
Consuming RESTful APIs
RESTful Principles
•Identifiable Resources
•Manipulation of Resources
•Self-Descriptive Messages
•Hypermedia is the Engine
RESTful APIs
RESTful Resources
• Authentication Resources
• Auth Tokens, Username / Password pairs
• Data Resources
• Personal Data, Public Data, GeoData, etc...
• Service Resources
• API Keys, Endpoints, etc...
Manipulation of Resources
Self-Descriptive Messages
Security!!
Security in RESTful APIs
• Transport Security
• SSL
• Message Security
• Encryption (Optional)
• Authentication
• Tokens
• Signing Messages
• Authorization
• Controlled by Service
Authentication Flavors
Authentication Examples
Spot the Anti-Pattern
OAuth 1.0
OAuth 2.0
Consuming REST in .NET
• RestSharp
• http://restsharp.org
• Hammock REST
• http://hammock.codeplex.com/
Using Wrapper Libaries
• Automate Some Tasks
• Deserializing responses into objects
• Managing request life-cycles
• Simplify others
• OAuth Workflow
• Handling service errors
CODE

More Related Content

What's hot

How Public Sector Entities are Advancing Their Security and Governance Capabi...
How Public Sector Entities are Advancing Their Security and Governance Capabi...How Public Sector Entities are Advancing Their Security and Governance Capabi...
How Public Sector Entities are Advancing Their Security and Governance Capabi...Amazon Web Services
 
Rev Your Engines - SharePoint Performance Enhancements
Rev Your Engines - SharePoint Performance EnhancementsRev Your Engines - SharePoint Performance Enhancements
Rev Your Engines - SharePoint Performance EnhancementsEric Shupps
 
Elastic & Azure & Episever, Case Evira
Elastic & Azure & Episever, Case EviraElastic & Azure & Episever, Case Evira
Elastic & Azure & Episever, Case EviraMikko Huilaja
 
Episerver and search engines
Episerver and search enginesEpiserver and search engines
Episerver and search enginesMikko Huilaja
 

What's hot (6)

How to paas the cloud
How to paas the cloudHow to paas the cloud
How to paas the cloud
 
How Public Sector Entities are Advancing Their Security and Governance Capabi...
How Public Sector Entities are Advancing Their Security and Governance Capabi...How Public Sector Entities are Advancing Their Security and Governance Capabi...
How Public Sector Entities are Advancing Their Security and Governance Capabi...
 
Rev Your Engines - SharePoint Performance Enhancements
Rev Your Engines - SharePoint Performance EnhancementsRev Your Engines - SharePoint Performance Enhancements
Rev Your Engines - SharePoint Performance Enhancements
 
Elastic & Azure & Episever, Case Evira
Elastic & Azure & Episever, Case EviraElastic & Azure & Episever, Case Evira
Elastic & Azure & Episever, Case Evira
 
Episerver and search engines
Episerver and search enginesEpiserver and search engines
Episerver and search engines
 
Windows Azure
Windows AzureWindows Azure
Windows Azure
 

Viewers also liked

Done 1450 Brickell
Done 1450 BrickellDone 1450 Brickell
Done 1450 Brickellchilliard
 
Facebook contest platforms
Facebook contest platformsFacebook contest platforms
Facebook contest platformsOlivier Gillin
 
Gamification to get your message across
Gamification to get your message acrossGamification to get your message across
Gamification to get your message acrossOlivier Gillin
 
How to Design Applications People Love
How to Design Applications People LoveHow to Design Applications People Love
How to Design Applications People LoveAaron Stannard
 
تعلمت؟؟!!!
تعلمت؟؟!!!تعلمت؟؟!!!
تعلمت؟؟!!!aaammmsss
 
Energy And Force English Activities[1]
Energy And Force English Activities[1]Energy And Force English Activities[1]
Energy And Force English Activities[1]ies el fontanal
 
161 Pc Pour 29 Sept2007
161 Pc Pour 29 Sept2007161 Pc Pour 29 Sept2007
161 Pc Pour 29 Sept2007chilliard
 
Location Services and Bing Maps in Windows Phone 7
Location Services and Bing Maps in Windows Phone 7Location Services and Bing Maps in Windows Phone 7
Location Services and Bing Maps in Windows Phone 7Aaron Stannard
 
Up Close & Personal
Up Close & PersonalUp Close & Personal
Up Close & PersonalManoj Chandra
 
Retirement Plan Fiduciary Services
Retirement Plan Fiduciary ServicesRetirement Plan Fiduciary Services
Retirement Plan Fiduciary ServicesBrian_Roberts
 
Mobile Payments and Mobile Commerce
Mobile Payments and Mobile CommerceMobile Payments and Mobile Commerce
Mobile Payments and Mobile CommerceOlivier Gillin
 

Viewers also liked (14)

Done 1450 Brickell
Done 1450 BrickellDone 1450 Brickell
Done 1450 Brickell
 
Facebook contest platforms
Facebook contest platformsFacebook contest platforms
Facebook contest platforms
 
SENTIERI FORMATIVI
 PER IL PERSONALE DI VENDITA
SENTIERI FORMATIVI
 PER IL PERSONALE DI VENDITASENTIERI FORMATIVI
 PER IL PERSONALE DI VENDITA
SENTIERI FORMATIVI
 PER IL PERSONALE DI VENDITA
 
Gamification to get your message across
Gamification to get your message acrossGamification to get your message across
Gamification to get your message across
 
How to Design Applications People Love
How to Design Applications People LoveHow to Design Applications People Love
How to Design Applications People Love
 
تعلمت؟؟!!!
تعلمت؟؟!!!تعلمت؟؟!!!
تعلمت؟؟!!!
 
Energy And Force English Activities[1]
Energy And Force English Activities[1]Energy And Force English Activities[1]
Energy And Force English Activities[1]
 
161 Pc Pour 29 Sept2007
161 Pc Pour 29 Sept2007161 Pc Pour 29 Sept2007
161 Pc Pour 29 Sept2007
 
Location Services and Bing Maps in Windows Phone 7
Location Services and Bing Maps in Windows Phone 7Location Services and Bing Maps in Windows Phone 7
Location Services and Bing Maps in Windows Phone 7
 
Up Close & Personal
Up Close & PersonalUp Close & Personal
Up Close & Personal
 
Retirement Plan Fiduciary Services
Retirement Plan Fiduciary ServicesRetirement Plan Fiduciary Services
Retirement Plan Fiduciary Services
 
Gamification cases
Gamification casesGamification cases
Gamification cases
 
Intro to Node
Intro to NodeIntro to Node
Intro to Node
 
Mobile Payments and Mobile Commerce
Mobile Payments and Mobile CommerceMobile Payments and Mobile Commerce
Mobile Payments and Mobile Commerce
 

Similar to Consuming REST in .NET

APIsecure 2023 - Understanding and Identifying Threats Against APIs, Shannon ...
APIsecure 2023 - Understanding and Identifying Threats Against APIs, Shannon ...APIsecure 2023 - Understanding and Identifying Threats Against APIs, Shannon ...
APIsecure 2023 - Understanding and Identifying Threats Against APIs, Shannon ...apidays
 
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...Ruby Meditation
 
An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST Ram Awadh Prasad, PMP
 
Demystifying Web Application Security - JSFoo 2018
Demystifying Web Application Security - JSFoo 2018Demystifying Web Application Security - JSFoo 2018
Demystifying Web Application Security - JSFoo 2018shyamsesh
 
DefCamp 2013 - Http header analysis
DefCamp 2013 - Http header analysisDefCamp 2013 - Http header analysis
DefCamp 2013 - Http header analysisDefCamp
 
Creating a RESTful api without losing too much sleep
Creating a RESTful api without losing too much sleepCreating a RESTful api without losing too much sleep
Creating a RESTful api without losing too much sleepMike Anderson
 
Web Application Security - DevFest + GDay George Town 2016
Web Application Security - DevFest + GDay George Town 2016Web Application Security - DevFest + GDay George Town 2016
Web Application Security - DevFest + GDay George Town 2016Gareth Davies
 
Shifting security left simplifying security for k8s open shift environments
Shifting security left simplifying security for k8s open shift environmentsShifting security left simplifying security for k8s open shift environments
Shifting security left simplifying security for k8s open shift environmentsLibbySchulze
 
Cloud identity management meetup 150108
Cloud identity management meetup 150108Cloud identity management meetup 150108
Cloud identity management meetup 150108Morteza Ansari
 
Owasp Indy Q2 2012 Cheat Sheet Overview
Owasp Indy Q2 2012 Cheat Sheet OverviewOwasp Indy Q2 2012 Cheat Sheet Overview
Owasp Indy Q2 2012 Cheat Sheet Overviewowaspindy
 
Help! I Have An Identity Crisis: A look at various mechanisms of Single Sign On
Help! I Have An Identity Crisis: A look at various mechanisms of Single Sign OnHelp! I Have An Identity Crisis: A look at various mechanisms of Single Sign On
Help! I Have An Identity Crisis: A look at various mechanisms of Single Sign OnSaloni Shah
 
Rest API Security
Rest API SecurityRest API Security
Rest API SecurityStormpath
 
Secure JAX-RS
Secure JAX-RSSecure JAX-RS
Secure JAX-RSPayara
 

Similar to Consuming REST in .NET (20)

Spa Secure Coding Guide
Spa Secure Coding GuideSpa Secure Coding Guide
Spa Secure Coding Guide
 
APIsecure 2023 - Understanding and Identifying Threats Against APIs, Shannon ...
APIsecure 2023 - Understanding and Identifying Threats Against APIs, Shannon ...APIsecure 2023 - Understanding and Identifying Threats Against APIs, Shannon ...
APIsecure 2023 - Understanding and Identifying Threats Against APIs, Shannon ...
 
Web security and OWASP
Web security and OWASPWeb security and OWASP
Web security and OWASP
 
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
Data encryption for Ruby web applications - Dmytro Shapovalov (RUS) | Ruby Me...
 
An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST
 
API IN(SECURITY)
API IN(SECURITY)API IN(SECURITY)
API IN(SECURITY)
 
Demystifying Web Application Security - JSFoo 2018
Demystifying Web Application Security - JSFoo 2018Demystifying Web Application Security - JSFoo 2018
Demystifying Web Application Security - JSFoo 2018
 
DefCamp 2013 - Http header analysis
DefCamp 2013 - Http header analysisDefCamp 2013 - Http header analysis
DefCamp 2013 - Http header analysis
 
Creating a RESTful api without losing too much sleep
Creating a RESTful api without losing too much sleepCreating a RESTful api without losing too much sleep
Creating a RESTful api without losing too much sleep
 
Windows 8 Apps and the Outside World
Windows 8 Apps and the Outside WorldWindows 8 Apps and the Outside World
Windows 8 Apps and the Outside World
 
Web Application Security - DevFest + GDay George Town 2016
Web Application Security - DevFest + GDay George Town 2016Web Application Security - DevFest + GDay George Town 2016
Web Application Security - DevFest + GDay George Town 2016
 
Shifting security left simplifying security for k8s open shift environments
Shifting security left simplifying security for k8s open shift environmentsShifting security left simplifying security for k8s open shift environments
Shifting security left simplifying security for k8s open shift environments
 
AWS Security & Compliance
AWS Security & ComplianceAWS Security & Compliance
AWS Security & Compliance
 
Cloud identity management meetup 150108
Cloud identity management meetup 150108Cloud identity management meetup 150108
Cloud identity management meetup 150108
 
On being RESTful
On being RESTfulOn being RESTful
On being RESTful
 
Owasp Indy Q2 2012 Cheat Sheet Overview
Owasp Indy Q2 2012 Cheat Sheet OverviewOwasp Indy Q2 2012 Cheat Sheet Overview
Owasp Indy Q2 2012 Cheat Sheet Overview
 
Help! I Have An Identity Crisis: A look at various mechanisms of Single Sign On
Help! I Have An Identity Crisis: A look at various mechanisms of Single Sign OnHelp! I Have An Identity Crisis: A look at various mechanisms of Single Sign On
Help! I Have An Identity Crisis: A look at various mechanisms of Single Sign On
 
Rest API Security
Rest API SecurityRest API Security
Rest API Security
 
Secure JAX-RS
Secure JAX-RSSecure JAX-RS
Secure JAX-RS
 
Api crash
Api crashApi crash
Api crash
 

Recently uploaded

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 

Recently uploaded (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 

Consuming REST in .NET

Editor's Notes

  1. This talk is for .NET developers who need a 100 level overview of REST APIs and want to know how to consume some common ones using publicly available tools in .NET. This isn’t for experts or WCF wizards who want to craft their own REST APIs using the WCF Rest Toolkit.
  2. Here’s what you should get out of the talk today: -Background on REST itself -An understanding of the high level process for consuming REST APIs -The principals behind the design of the REST architecture -A broad understanding of the security issues in REST and why it’s so important -And a look at some rough examples of how to put popular REST wrapper libraries like RestSharp and Hammock REST into practice.
  3. So REST is everywhere – most major online properties give developers some method of leveraging their content or services via a public REST API. Facebook, Foursquare, Twitter, Flickr, Twilio, Bing, Google, you name it.
  4. What does REST stand for? It stands for Representational State Transfer – it’s a method for passing persistent data, or state, to a client for viewing or manipulation.
  5. So what is REST? Well it’s not a standard like SOAP or WSDL. It’s just an architectural pattern, and any movement towards standardization has been done so in a de facto fashion by REST API authors, not a standards governing body like the IETF.
  6. Here’s the high-level view of consuming REST APIs – you have three actors: the client, which can be anything – a web page, a mobile device, a computer, or anything that can access the internet; you have the Internet itself as an actor; and then finally you have the endpoint on the other side of the network. The way these interop together is your client issues a request across the network, consisting of an HTTP verb plus a target URI and perhaps some other dimensions found within the realm of hypermedia. The REST endpoint receives the request and in return sends a serialized, MIME-encoded entity across the network. The client receives the entity, deserializes it into a useful object, and proceeds to do something awesome with it. That’s REST API consumption in a nutshell.
  7. There are four core principals to the design of REST architectures: The first is that all resources are identifiable – meaning that all of the possible methods, which are themselves resources, you can hit in a REST API are exposed in some manner and those methods can enable you to gain access to the other resources you need to make additional calls, such as authorization tokens. The second is that all resources can be manipulated – a client has the ability to take a resource, do something to it, and persist the change to the service. The third principal is that all messages received from a REST service are self-descriptive, meaning that they use a MIME type and can be easily understood by a human. The final principal is that hypermedia is the engine – which means that REST utilizes the HTTP protocol and the standard “hyperlink” construct as its functional form. These will all make more sense in the next few slides.
  8. So what are “identifiable” resources in the context of REST – typically we’re referring to URIs which expose endpoints for REST API methods. Take this method from the Twitter REST API – you have an authority which demarcates the common service point for all methods within this API, you have an API version number which is a good practice for gradually phasing out older versions of REST APIs, you have a method, and then you have the parameters for that method supplied as query string arguments. Method arguments can also be passed as HTTP headers within a request, but it’s totally up to the people who designed the API you’re working with to determine where, when, and how they’re used in conjunction with other argument types such as query strings and HTTP Verbs.
  9. We already talked about resources from the perspective of service methods themselves, but I also wanted to give you the full landscape of what REST API developers mean when they’re referring to resources. Resources can also mean authentication resources, data from the service itself, and other macro-level resources like API keys and endpoints.
  10. Manipulation of resources – first, I’d like to thank Wikipedia for allowing me to steal this. Second, this table depicts what the initial REST authors meant by manipulation of resources. The top row shows how an example REST API might refer to a collection of available resources using typical syntax – you might use a method like this for querying a bunch of your user’s Twitter status updates over the past week or two. Typically you’d use a GET operation for retrieving a list of URIs which describe individual elements in the collection, the PUT verb to actually replace the entire collection, a POST verb to add a new member to the collection, and the DELETE verb to actually remove the entire collection. Obviously how a REST API actually uses these verbs is totally up to the API designer, but in case any of you have the crazy idea of allowing people to make changes to persistent objects on your REST API using GET verbs, bear in mind that accidentally clicking on a link which points to that particular endpoint on your API could result in a lot of data being lost. That’s why it’s a good idea to make developers work a little bit harder to change state by requiring stickier verbs like PUT and POST for operations that change state. Now if you look at the second row of the table here, it’s the same set of operations but just for a single entity in a collection. And you could in theory extend this out recursively if you wanted to drill down into a collection of collections or something like that. You just keep adding more crap to the end of the URL and hey, your REST API gets that much larger. That’s RESTful behavior, which naturally lends itself to extensibility.
  11. Self Descriptive messages – this is a sample response from the Flickr API. Now, we can’t make sense of all of the details per say, but we can obviously read the message as it’s sent in UTF-8 encoded text and based on the structure of the XML we can get a general idea of what this is for. This is the essence of what the original REST authors meant when they said “self-describing messages.”
  12. Security gets its own big section in this talk as it’s pivotal to what we do as developers who work with user’s data. You’re not merely hitting a remote service endpoint over a network – you’re dealing with users’ private data when you work with most REST APIs, and we need to keep malicious users out the best we can.