Postman
Contributors: Alanna Zhou
Download Postman
Highly recommend you install Postman as soon as the course starts! It will be crucial to assignments and practically any backend dev-ing.
Why use Postman
If you hit an endpoint in your browser, the best you can do is hit endpoints that are just GET requests (see the section below on how to hit an endpoint). There's no easy way for you to test parts of your backend API that handle POST and DELETE requests -- so how do you know if you are responding in the way that you coded and expected? Use Postman!
Postman lets you do all of these things with a super helpful user interface. You can even organize all of the endpoints your testing into folders and workspaces, as well as share them with whoever is collaborating with you on a project!
How to "hit" an endpoint in general
When you run your code locally (aka on local host), your endpoint at port 5000 can be reachable at all of these options:
This is because 0.0.0.0, 127.0.0.1, and localhost all mean you're running off of local host! You can read more about the differences on this stack exchange post.
Common mistake #1
If you can't hit your endpoint, ensure that you are also hitting the right port that your code is running on! This is usually declared somewhere at the bottom of your app.py:
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)Common mistake #2
There's a difference between http and https, so make sure you are hitting http!
How to make a GET request in Postman
Select
GETfrom the dropdown to the left of theEnter request URLinput text field barInput the endpoint receiving the
GETrequest into the text field barClick the blue
sendbuttonPostman will now show you either your successful
JSONresponse at the bottom, or some errors for you to fix
GET Query Parameters
GET Query ParametersGET requests can also have parameters, and there are two ways to hit an endpoint with parameters:
1. Type in your GET parameters manually into the input text field bar
GET parameters manually into the input text field barwhere key1 and key2 are the names of your parameters, and value1 and value2 are the corresponding values (you can have as many as you want, but this example only has two key-value pairs).
For example, if I'm designing backend that returns some information about a student given their first name, last name, and age, I could type this URL into the text field input bar:
2. Input your GET parameters into the table and let Postman automatically fill in your URL
GET parameters into the table and let Postman automatically fill in your URL
Just type away under Params (select this option in the banner under the URL) and the checkboxes will automatically be checked and your URL will automatically have the params filled in!
How to make a POST request in Postman
Select
POSTfrom the dropdown to the left of theEnter request URLinput text field barInput the endpoint receiving the
POSTrequest into the text field barClick on
Bodyin the banner right below (next toHeadersandPre-request Script)Select
rawSelect
JSONfrom the dropdown to the right ofrawType in your
POSTrequest body inJSONformatClick the blue
sendbuttonPostman will now show you either your successful
JSONresponse at the bottom, or some errors for you to fix
Here's an example of what a POST request could look like, with the { "first" ... "true" } information being the POST request body written in JSON format.

Note that JSON can take in strings, integers, and booleans.
Last updated
Was this helpful?