• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Demystifying REST - SFRails meetup
 

Demystifying REST - SFRails meetup

on

  • 1,971 views

 

Statistics

Views

Total Views
1,971
Views on SlideShare
1,971
Embed Views
0

Actions

Likes
0
Downloads
3
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Demystifying REST - SFRails meetup Demystifying REST - SFRails meetup Presentation Transcript

    • Demystifying REST Kirsten Jones, API Ninja, 3Scale
    • Kirsten Jones - @synedra API Ninja (that’s me!)  Developer Evangelist  Worked at Netflix, LinkedIn  Lots of experience helping developers  Language Polyglot  Where I came from... 2
    • Kirsten Jones - @synedra This talk  HTTP - Quick Overview  REST Web Services  Debugging Tips and Techniques
    • Kirsten Jones - @synedra Want to play along?  HTTPScoop  Macintosh only  Pretty (my favorite)  Doesn’t support SSL  http://www.tuffcode.com  Fiddler  Windows only  Supports SSL  http://fiddler2.com 4
    • Kirsten Jones - @synedra HTTP  HyperText Transfer Protocol  Used for conversations between web clients and servers  Supports verbs for GET, PUT, POST, DELETE  Includes support for query parameters
    • Kirsten Jones - @synedra How does HTTP Work?  Client sends a request  Method  URL  Headers  Parameters  Body  Server replies with a response  Content  Status  Headers
    • Kirsten Jones - @synedra What do you Mean, Status? HTTP response codes for dummies.  50x: we f*cked up.  40x: you f*cked up.  30x: ask that dude over there.  20x: cool. Props to @DanaDanger for that one
    • Kirsten Jones - @synedra An example request  Chrome browser sends a request to Google  Method: GET  URL: http://www.google.com  Headers: ▪ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/ *;q=0.8 ▪ Accept-Language: en-US,en;q=0.8 ▪ Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 ▪ Connection: keep-alive ▪ User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19 ▪ Accept-Encoding: gzip,deflate,sdch ▪ Cookie: NID=59=EudJ2a15ql8832PCysQA0qchtuvGWMoA7rkp79VpIYAQ8- j42IO17LFudCYNMXm9l6SHcu3YgrGRCdrRCyM468xPZaOek4Pi- AXQ8eARqU1SGYx6y7_9LW-c3HHb-vs2;
    • Kirsten Jones - @synedra Example Response  Google sends a response  Headers: ▪ Content-Length: 24716 ▪ Content-Encoding: gzip ▪ Set-Cookie: NID=59=F48kbwfwOi-qCHJyrnMSUlDBVxK- ZVKZpq5B5jttt_25IRN4lS-0rQcVttq- dnOIlQzafw1i4HPQAO0RpZ7NuC0WCKWta7SYoekx0-- YGf2zIFZ9VXIKS-_UEaOH9iBe; expires=Sat, 10-Nov-2012 21:26:46 GMT; path=/; domain=.google.com; HttpOnly ▪ Expires: -1 ▪ Server: gws ▪ X-XSS-Protection: 1; mode=block ▪ Cache-Control: private, max-age=0 ▪ X-Frame-Options: SAMEORIGIN ▪ Content-Type: text/html; charset=UTF-8 ▪ Date: Fri, 11 May 2012 21:26:46 GMT  Content: A bunch of HTML  Status: 200
    • Kirsten Jones - @synedra Example: HTTPScoop Request
    • Kirsten Jones - @synedra Example: HTTPScoop Headers
    • Kirsten Jones - @synedra Example: HTTPScoop Request/Response
    • Kirsten Jones - @synedra REST APIs Leverage HTTP  Uses URL paths to define resources  Create, Read, Update, Delete  POST, GET, PUT, DELETE  Error Codes  HTTP Status Codes  Request parameters  Query parameters  Response types and configuration  Headers
    • Kirsten Jones - @synedra Example REST Request  Blog Info from Tumblr  GET (read) http://api.tumblr.com/v2/ blog/synedra.tumbler.com/info  Requires api_key sent as parameter
    • Kirsten Jones - @synedra Example Request:
    • Kirsten Jones - @synedra Example Request:  Headers
    • Kirsten Jones - @synedra Example Request:  Request/Response
    • Kirsten Jones - @synedra Example REST Response Status: 200 Content: {"meta": {"status":200,"msg":"OK”}, "response":{ "blog":{"title":"Untitled","posts":0, "name":"synedra", "url":"http://synedra.tumblr.com/", "updated":0, "description":"","ask":false,"likes":0}}}
    • Kirsten Jones - @synedra Troubleshooting API Calls  HTTPScoop to understand your calls  Compare against a known good call  Simplify request (weird chars?)  Try a different (simpler) resource  Ask good questions 19
    • Kirsten Jones - @synedra PreventingPreventableProblems  Use existing libraries/code/examples  Code Defensively  Test Defensively  Test Frequently  Handle Errors Gracefully  Pass back errors/log issues 20
    • Kirsten Jones - @synedra Questions? Information about me:  @synedra on twitter  kirsten@3scale.net  http://www.princesspolymath.com  API Strategy Conference (Oct. 23-25) Thanks to Twilio!!! 21