Stève Sfartz @CiscoDevNet
Developer Experience Manager and API Design Lead
Advanced Postman
for Better APIs
#WebSummit - Nov 5th 2018
• API Veteran, Hobbyist Coder, Hands-On Architect
• Building code samples & dev tools, provide feedback, fill gaps
• Manager of a WW team of Developer Advocates
• Application Development Practices (IoT, Collab, Cloud, DevOps)
• Technical lead for the Cisco « API Style Guide »
• What excites me? Providing great Developer eXperiences
About me: //Cisco/DevNet/SteveSfartz
webex: stsfartz@cisco.com
twitter: @SteveSfartz
github: @ObjectIsAdvantag
http://getpostman.com
• Free tool to forge API requests, examine responses
Forging a Request
Terminology of a REST API query
GET /../repos?page=1 HTTP/1.1 accept: application/json
HTTP 200 OK
browser api.github.com:443
method path protocol
status code
https://api.github.com/users/CiscoDevNet/repos?page=1&per_page=2
headers
URL:
response body
HTTP
request
HTTP
response
api endpoint
JSON payload
parameters
method
url
request
headers
status code
response headers
content-type
response
body
query parameters
HTTP Request : Methods
 GET – retrieve contents from the server
 HEAD – only get the HTTP headers & status code (don't GET the body)
 PUT – update content
 PATCH – partial update
 POST – create content
 DELETE – delete content
 OPTIONS – retrieve contextual information before issuing a request
 check W3C RFC 7230-7 to get an exhaustive list of HTTP/1.1 methods
Environment Variables
Code Generation
Generate code with Postman
1. Start from a REST call
2. Select your favorite language
3. Protect your token or leverage OAuth
4. Run your code
Collections
To go further: import a Cisco Spark colllection
https://github.com/CiscoDevNet/postman-webex
http://bit.ly/postman-webex
Postman Collections at Cisco
Postman Collection for Webex Devices
Postman Collection for Webex Teams
Postman Collection for Meraki
The Power of Collections
Documenting your API
Scripting
Automated Testing
Newman
Run from the Command Line
Developer Resources
• Postman collections for Webex Teams REST API
• https://github.com/CiscoDevNet/postman-webex
• Postman collections for Webex Devices xAPI
• https://github.com/CiscoDevNet/postman-xapi
• Postman collection for Meraki
• https://communities.cisco.com/community/developer/meraki/blog/2
017/05/30/postman-collection-for-the-meraki-dashboard-api--
updated
• https://documenter.getpostman.com/view/897512/meraki-
dashboard-api/2To9xm
Join DevNet by scanning the QR code and becoming a member. Learn about what we have to offer in
the booth and why Cisco is atWeb Summit. Go to a specific demo pod based on interest, sign up for
mentoring, go to our web site to learn more.
Join Cisco DevNet sessions today!
Join DevNet and talk to our mentors available about how you can engage and get started with Cisco DevNet.
You can also attend a workshop on Wednesday or separate session for startups or design thinking or how to
build bridges from applications to infrastructure.
If you’re a customer or partner, book your visit at the Cisco Innovation Center closest to you
Learn more about the Innovation Center
in Italy:
Innovation Exchange
link: https://www.cisco.com/c/m/it_i
t/campaigns/digitaliani/innovazione
/innovation_exchange.html
Learn more about Innovation Center
Network:
IC network
Link: https://www.cisco.com/c/e
n/us/solutions/innovation-
centers.html

Advanced Postman for Better APIs - Web Summit 2018 - Cisco DevNet

  • 1.
    Stève Sfartz @CiscoDevNet DeveloperExperience Manager and API Design Lead Advanced Postman for Better APIs #WebSummit - Nov 5th 2018
  • 2.
    • API Veteran,Hobbyist Coder, Hands-On Architect • Building code samples & dev tools, provide feedback, fill gaps • Manager of a WW team of Developer Advocates • Application Development Practices (IoT, Collab, Cloud, DevOps) • Technical lead for the Cisco « API Style Guide » • What excites me? Providing great Developer eXperiences About me: //Cisco/DevNet/SteveSfartz webex: [email protected] twitter: @SteveSfartz github: @ObjectIsAdvantag
  • 3.
  • 4.
  • 5.
    Terminology of aREST API query GET /../repos?page=1 HTTP/1.1 accept: application/json HTTP 200 OK browser api.github.com:443 method path protocol status code https://api.github.com/users/CiscoDevNet/repos?page=1&per_page=2 headers URL: response body HTTP request HTTP response api endpoint JSON payload parameters
  • 6.
  • 7.
    HTTP Request :Methods  GET – retrieve contents from the server  HEAD – only get the HTTP headers & status code (don't GET the body)  PUT – update content  PATCH – partial update  POST – create content  DELETE – delete content  OPTIONS – retrieve contextual information before issuing a request  check W3C RFC 7230-7 to get an exhaustive list of HTTP/1.1 methods
  • 8.
  • 10.
  • 11.
    Generate code withPostman 1. Start from a REST call 2. Select your favorite language 3. Protect your token or leverage OAuth 4. Run your code
  • 13.
  • 14.
    To go further:import a Cisco Spark colllection https://github.com/CiscoDevNet/postman-webex http://bit.ly/postman-webex
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
    The Power ofCollections
  • 21.
  • 23.
  • 26.
  • 29.
  • 30.
    Run from theCommand Line
  • 31.
    Developer Resources • Postmancollections for Webex Teams REST API • https://github.com/CiscoDevNet/postman-webex • Postman collections for Webex Devices xAPI • https://github.com/CiscoDevNet/postman-xapi • Postman collection for Meraki • https://communities.cisco.com/community/developer/meraki/blog/2 017/05/30/postman-collection-for-the-meraki-dashboard-api-- updated • https://documenter.getpostman.com/view/897512/meraki- dashboard-api/2To9xm
  • 32.
    Join DevNet byscanning the QR code and becoming a member. Learn about what we have to offer in the booth and why Cisco is atWeb Summit. Go to a specific demo pod based on interest, sign up for mentoring, go to our web site to learn more. Join Cisco DevNet sessions today!
  • 33.
    Join DevNet andtalk to our mentors available about how you can engage and get started with Cisco DevNet. You can also attend a workshop on Wednesday or separate session for startups or design thinking or how to build bridges from applications to infrastructure.
  • 34.
    If you’re acustomer or partner, book your visit at the Cisco Innovation Center closest to you Learn more about the Innovation Center in Italy: Innovation Exchange link: https://www.cisco.com/c/m/it_i t/campaigns/digitaliani/innovazione /innovation_exchange.html Learn more about Innovation Center Network: IC network Link: https://www.cisco.com/c/e n/us/solutions/innovation- centers.html

Editor's Notes

  • #2 Advanced Postman for better APIs: with 5 million developers, Postman is the defacto tool to design and test your APIs. Join this session to learn about Postman more advanced features.
  • #4 If you have not installed Postman, this is the last call. Go to getpostman.com, Click Chrome App for the purpose of this training
  • #6 The same HTTP principles that apply to the Web (HTML page) - apply to Web APIs Here ‘s what happens when you consume the github API, More concretely : you hit an Endpoint (here the host: github.com, port: 443), remember it is what HTTPS defaults to, the connection is established and the HTTP protocol is used as specified by the scheme, the resource path /CiscoDevNet is asked for, with a GET method, the web browser adds an Accept Header to the request because an HTML page is what it expects the server to return This is the request, now let’s look at the answer : the github server returns on the same channel a response with the statuts code 200 to tell everything went OK and it writes the JSON contents on the wire Now, we got this HTTP intrinsics, we’re ready to place the call over the wire with POSTMAN. -- ADVANCED DO : open Chrome, go to github, open Dev Toolbar, show what’s happening Several resources are being accessed To different endpoints And different types of Data are being sent and received. That’s the way the Web works, we issue HTTP calls, asking for resources. Then all you need to know to start building calls yourself.
  • #7 Now let’s place our HTTP request to github.com Leave the GET method as is. Enter the URL of the resource. Press the Send button DO : open POSTMAN, issue the call https://github.com/CiscoDevNet Postman issues the HTTP call on your behalf, and shows the response transmitted by the Github service : statuts of 200 OK if everything went ok If you get 404, the URL is malformed The HTML page contents are placed in the Body Note that the HTML content-type specified by the server is also displayed If you encounter an issue, ask for assistance in the Spark room and sending a Snapshot of your work in Postman may be your best bet to get an hand from the team.
  • #8 First, let’s start with the methods. We’ve just experienced GET with the Postman calls. The 4 major methods are GET / POST / PUT / DELETE These methods enable HTTP Clients to create / read / update / delete Contents on the Web API Server. Worth mentionning other methods exists : HEAD, PATCH, OPTIONS, though you probably won’t use them during your first interactions with Web APIS.
  • #15 A Postman collection regroups a set of API requests You can save any requests you forge manually into a collection, group several requests and share your collections with Postman If you need to inject dynamic parameters such as API token you can inject them using the {{ variable }} notation. Note that it is also possible to share environments with Postman
  • #26 And enrich your environment on the way
  • #31 [sudo] npm install newman -g Export your collection Run newman > newman run "Postman_Tour.postman_collection.json"