How to use Postman to test API functionality, postman, how to download postman, how to use postman, postman apis, run apis in postman

How to use Postman to test API functionality

Having created a well-structured API (Application Programming Interface) with all the functions and functionalities included, you may reach a point you want to test the API functionality so that you can share with other developers or use it in other platforms like Android App. This article will assist you on how you can use Postman to test the API functionality so that you can identify whether there are problems before deploying to active applications to use it.

 

What is Postman?

Postman is a computer application that is used as a tool for API testing. Postman collects your API request and acts as a middle man so that your request can be sent to the webserver and immediately returns and displays the result in its interface. Postman is created in a way that is simple to use with an interface that is straightforward as it does not require any coding, it’s just selecting the method you want to use, and keying your API link and the parameters if they are there, and then you send and wait for a response.

Postman is an open-source software meaning you can download without license registration which makes it easy to use for any developer. To download Postman, visit the official postman download link which is https://www.postman.com/downloads/, and follow the instructions to install.

Once the setup is complete, open it and you will find an interface as below

 

How to use Postman to test API functionality

Using Postman to test how the API is working

In our previous article, we created a login REST API using PHP and MYSQL https://www.solutionspacenet.com/post/create-a-rest-api-in-php which was as below

<?php  
header("Content-Type:application/json");
$con=mysqli_connect("localhost","username","password1","databasename");
$email = $_POST["email"];
$password = $_POST["password"];
if(mysqli_num_rows(mysqli_query($con,"SELECT * FROM customers WHERE Email='$email' AND Password='$password'"))> 0){
$json = array("status" => 200,'message' => "Success");
}else{
$json = array("status" => 300,'message' => "Error");
}
echo $json;
mysqli_close($con);
?>

 

I saved the above-filed login.php in my public_html folder inside a folder called APIs of this server space. So my full link to access the login file will be https://www.solutionspacenet.com/apis/login.php

To get the results, it means I will have to send some data which am collecting as email and password in this case they are called parameters sent as form data.

The method we are using is POST

The representation of the same is as follows

  • For a successful response

 

How to use Postman to test API functionality

 

  • For a response with values that do not match ones in the database

How to use Postman to test API functionality

 

You will note that, in the postman program, each section is displayed in a way one can understand, in that,

The method section is in the top left

URL section follows the method

Below it you will find the parameter section in the form data

The response section is left with a wider area at the bottom

 

To share the API with another user you can use the following simple format that everyone will understand

LOGIN API                                                        // title of the API 
URL https://www.solutionspacenet.com/apis/login //URL to the API file
PARAMS email,password // values to post
RESPONSE // response value
{
"status": 200,
"message": "Success"
}

 

With that, we have highlighted the important steps of how to use Postman to test API functionality.