Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Before we go deeper into the topics, let's make sure we understand the basics. If you are new to APIs, here is a quick introduction.
An API is essentially an interface to a server that has some data or does some actions. To understand the concept of an interface, think about any power outlet at your home; it does not matter which device you want to power your laptop, a washing machine, or a tv. The outlet on a wall is designed to accept any plug following a predefined specification. Before diving deep into the introduction to postman, Let's have a basic introduction about HTTP and API.
What is HTTP?
HTTP(Hypertext Transfer Protocol ) is an application-layer protocol for transmitting hypermedia documents, such as HTML. It is designed for communication between web browsers and web servers.
HTTP Request / Response
It is a Communication between clients and servers. It is done by Requests and Responses.
A Browser sends an HTTP request to the web.
A web server receives the request from the client.
The server runs an application to process the request.
Then the server returns an HTTP response (Output) to the browser.
The client (the browser) receives the response from the server.
What is an API?
API stands for application programming interface and API essentially is a component that enables the communication between two different applications and these two different applications can be completely different from each other.
For example, there can be an application that is developed over a Linux platform using Java and its uses oracle as it's database, there can be another application which is developed over a Windows platform using C++ and it uses my SQL server as its database.
Now, these two applications cannot communicate with each other directly, but with the help
of API they can, so API enables the communication between two different applications.
A postman is a tool for interacting with web-based APIs that work over the internet. It is used for back-end testing where we enter the end-point URL, send the request to the server, and get the response back from the server.
An API is like a power outlet that a server offers, and instead of electricity, we get data, we use postman to plug into this outlet, but instead of using a physical cable, we use the internet.
Postman can help us connect to the API and also make sure that the process of sending and receiving data is much easier. Without that interface to the server, it will be much harder to communicate.
So, this is why we need Postman. Now, let's have a look at the Postman Window:
This is the main window which is called the Builder window. Where we will have our actual request and response so all our API requests will be created here and we will get the response at the bottom.
A drop-down button that has all the various HTTP methods as options is just to the left of it. Select POST if you want to POST to the URL which you have specified.
You can see the “Send” button used to send the request to the server or the app in this case.
Why Postman?
Easy to manage, you can use it anywhere, simply logging in to the Postman account.
In POSTMAN, we can pass the API call and check the API response, status codes, and payload.
Postman allows users to build independent collections for their API-call. Every set can be created using multiple requests and subfolders.
Successful HTTP response status verification is added to every API call to test the checkpoints.
Tests can be performed in several repetitions using the Collection Runner or Newman, saving time for repeated tests.
It helps in effectively debugging the tests, the postman console helps to track what data is being retrieved.
You can export or import collections and environments to enhance the sharing of files. You can also use a direct connection to share the collections.
How to Create an API request?
Let's get started:
We will go to the postman window. Here we have an option for workspace.
We can click here and select any of the existing workspaces, or we can also create a new one.
So, let’s create a new workspace, and this will be our personal workspace.
Let’s name this as Workspace1, we can also give some description which is optional and hit on create workspace.
So, now we are on Workspace1, and here we have this option to create a new element. We can create a new request from here or we can also go to (file > new > HTTP request) it will again give us this window where we can select a new HTTP request. We will select this create a new request and give a request name.
Now add the URL, we will copy it from here and go to our workspace and paste this URL, so this is our GET request. There’s no need to give anything else and it does not even require any headers.
Let us go with this very simple request and that's it. We will now hit the send button and you can see we have got the response.
In the response, you will get the body and in the body, you will get the actual body that is being returned from the server. You can view this in a pretty format, RAW format, any other format which is available or you can also select it from here so whatever representations are available for this response you will get them. So, you can see XML, HTML text and of course, JSON.
Now, we got the status of the request where 200 is the HTTP status code which is okay (OK), and then we have the time taken by the request or the response to come in milliseconds, and then we have the size. If you hover over the size you will get the actual size of the body and then the headers.
We have other sections like cookies, the headers which are there in the response are here and then of course in case you create any test you will get the test results.
FAQs
What are the core components of an HTTP request? The HTTP request includes important five key elements: HTTP methods – Set of request methods to perform the desired action for a given resource (GET, PUT, POST, DELETE) Uniform Resource Identifier (URI) – Describes the resource. HTTP Version, (Exp- HTTP v1.1) Request Headers, (Exp- Content-type : application/JSON, Content-Length : 511) Payload – It is a Request Body that includes message content.
Why does Postman accept Base64 encoding only? We use base64 mainly because it transmits the data into the textual form and sends it easier, such as HTML form data. Also, we can depend on the same 64 characters in any encoding language that we use.
What do you mean by the term environment in postman? An environment in postman is a set of key-value pairs. You can create multiple environments in postman that can be switched quickly with a button. There are two types of environment, Global and Local.
How can we stop executing requests or stop the collection run? We can Stop collection run with the command - postman.setNextRequest(null);
Key Takeaways
Postman is a rest client software that was started as a chrome extension but is now available as in native application also.
We discussed the important points to get started with the Postman API testing tool. We learned to install the Postman tool as a standalone application and discussed creating a simple request and looking at the response generated.
If you are pursuing a new career in Web Development, we suggest you get your fundamentals crystal clear with ourFull Stack Development course. This course will help you!
Live masterclass
Become a YouTube Analyst: Use Python to analyze viewers data
by Coding Ninjas
04 Feb, 2025
02:30 PM
Get hired as an Amazon SDE : Resume building tips
by Coding Ninjas
03 Feb, 2025
02:30 PM
Expert tips: Ace Leadership roles in Fortune 500 companies
by Coding Ninjas
03 Feb, 2025
12:30 PM
Become a YouTube Analyst: Use Python to analyze viewers data