Giter VIP home page Giter VIP logo

spring-mod-1-postman's Introduction

Testing APIs with Postman

Learning Goals

  • Review how to use Postman.

Review Using Postman

In the previous module, we learned how to use a tool called Postman as an API client when testing our servlets. We can use the same tool here too to test our Spring web applications!

So far, we've only created a controller class with GET requests, so we can easily test these in a browser's URL bar. But when we start introducing some other HTTP verbs, like POST, PATCH, and DELETE, it will be easier to use an API client, like Postman.

Even though we haven't introduced these other HTTP verbs yet in our controller class, let's do a quick refresh on how we can test our application using one of the GET requests we have defined.

In our spring-web-demo project, open up the LunchController class. Let's test with the getLunchSpecial() method! Run the SpringWebDemoApplication and then open up Postman, which should have already been installed from the previous module.

Once Postman is opened up, enter in HTTP request mapped to the getLunchSpecial() method in the controller class. Let's use monday as the path variable, so the GET request should be "http://localhost:8080/lunch-special/monday".

postman-lunch-query

Let's see if this works now! Click the "Send" button next to the request.

postman-lunch-result

Looks like the lunch special on Monday is a BLT sandwich! Yippee! Looks like everything works. We'll continue to use Postman as a testing tool. Now let's get into debugging our application.

Conclusion

API clients like Postman are extremely valuable to have in your API developer toolkit. They make it simple to interact with servers by giving you full control over how the response is being sent, with a nice interface for customizing the HTTP verb, URL, headers, and body.

In future lessons, we'll be expanding our API to handle non-GET requests, so being able to use a tool like Postman will make our API development much easier! It's also a great tool to use if you're exploring a third-party API for use in your projects.

Resources

spring-mod-1-postman's People

Contributors

alveem avatar kcleland0818 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

crives

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.