Introduction to Postman for API Development
In this post, I will use the Postman software to send and receive requests, POST data to the server and I will try to demo some other popular maneuvers. You can treat this article as your first contact with the Postman. So, lets get started !!
You can download Postman from here.
After downloading and installing the Postman, open the software.
Explaining the Interface
- The longest middle input field that looks something like a search bar is where the URL that we want to GET or POST or DELETE,etc. is fed.
- Just to the left of it, is a drop down button which has all the various HTTP methods as options. If you want to POST to the URL that you have specified, select POST.
- To the right of it is the params button. If you click on it, a new interface will appear. Params are basically the data that we want to send to the server with our request. We will use this params interface to POST to put app a new User.
- To the left of this button is the Send button which is used in sending the request to the server or the app in this case.
I think this much introduction to the interface is enough for us to get started. I will explain any other bit about the Postman on the fly if I have to.
So, lets get started with sending and receiving requests through Postman.
Sending and receiving requests through Postman
- Enter the url that you want to hit in the URL bar that i described above. I will put http:localhost:3000 in my case.
- Lets select our HTTP method to send the request as GET in the left button. Now click on the Send button.
- You will be returned HTML of the URL that you GET. I have selected the Preview to have a browser-like look.
- As you can see in the snap below that with the response from the server or the app, various headers are returned too with the main response.
Explanation of Header :
The first header returned is keep-alive . It basically means that the server’s connection with the user will not kill itself after some time.
My Personal Notes arrow_drop_up
- Content-length is the length of the html document that is returned.
- Date is the time the request has been made to the server to return the file.
- X-Powered-By sends Express as the app server is Express.
- Etag is an identifier for a specific version of the resource. It helps in saving time and bandwidth in case the user requests the same page again without any modifications, then the same file could be sent. You can read more about Etags here.
- For that, we will first GET the register form.
- Change the HTTP method of the next request that we are going to the send to POST. Open the Params tab of the Postman . This will help us in sending the form with the values that we want.
- After we hit enter, it POSTs the form with our key-value pairs and returns the response.
- The terminal also logs the registered user.
- Super easy API
- Wide range of functionality like support for all possible HTTP methods, saving progress, API to code conversion, changing environment of API development and many others.
- Helps to see the status codes, time taken for response and other performance parameters.
- Testing of APIs can be scheduled and automated.
- There is an option for importing of existing work so that you don’t have to start from scratch.
- Too many choices can overwhelm a beginner.
- It is not always true that an API developed in Postman will sure shot work in browser.
- Limited area of application(API testing and some other techniques).