Sunteți pe pagina 1din 8

12/24/2019 Manual API Testing using Postman for Beginners

BLOG

Manual API Testing using Postman for


Beginners
• API Management

By DEEPSHIKHA SINGH
Feb 27, 2019

Submit guest post

Manual API Testing using Postman for Beginners

Reliable API calls are critical to any decoupled application. Whether it a simple configuration change to an
entity or updating the Drupal core, both of them can alter the API response and lead to application-breaking
changes on the front-end. An API test suite can watch out for these API breaking changes by running a
slew of tests against your endpoint. And when you need to create an API test suite, Postman delivers.

Why Postman tool?

Postman is a simple GUI for sending HTTP requests and viewing responses. It is built upon an extensive set
of power tools, which are incredibly easy to use. Postman helps you perform a variety of functions ranging
from

· organizing requests into collection and folders,

· sharing common values across requests with environment variables,


https://www.srijan.net/blog/manual-api-testing-using-postman 1/8
·
12/24/2019 Manual API Testing using Postman for Beginners

scripting tests with the built-in node.js based runtime,

· and at last, automating it all using Postman’s very own CLI — Newman.

Install native Postman Application

Postman for Mac/Windows/Linux:

Go to https://www.getpostman.com/apps  and download the application based on the OS you are using and
follow the steps prompted to successfully install the Postman application.

After you have installed Postman successfully, your postman window should look like:

If you have accomplished this step, you are all set to take the next flight.

Making the first http request in Postman:

Since we have installed the Postman app successfully, it is now time to start testing the API with Postman by
making first ever HTTP request to server.

What is HTTP?

The Hypertext Transfer Protocol (HTTP) is designed to enable communications between clients and servers.
HTTP works as a request-response protocol between a client and server. A web browser may be the client,
and an application on a computer that hosts a website may be the server.

Example: A client (browser) submits an HTTP request to the server; then the server returns a response to
the client. The response contains status information about the request and may also contain the requested
content.

https://www.srijan.net/blog/manual-api-testing-using-postman 2/8
12/24/2019 Manual API Testing using Postman for Beginners

Most common http methods:

1. GET : The GET method is used to retrieve information from the given server using a given URI. Requests
using GET should only retrieve data and should have no other effect on the data.

2. POST : A POST request is used to send data to the server, for example, customer information, file upload,
etc. using HTML forms.

3. PUT : PUT is used to send data to a server to create/update a resource. Replaces all the current
representations of the target resource with the uploaded content.

4. PATCH : PATCH is used to update partial resources. For instance, when you only need to update one
field of the resource, PUTting a complete resource representation might be cumbersome and utilizes more
bandwidth.

5. HEAD : HEAD is almost identical to GET, but without the response body. HEAD transfers the status line
and the header section only.

6. DELETE : The DELETE method deletes the specified resource.

7. OPTIONS : The OPTIONS method describes the communication options for the target resource.

Testing GET Requests


Let’s now jump directly to test those API’s. Suppose we have an API which fetches the user information of a
particular application. To test this we will have to use GET request. The GET request is explained below:

For sample requests, visit https://reqres.in/

a. For making the first HTTP request(GET):

1. Make a collection in Postman — To make a collection in Postman, click on New->Collection-


>CollectionDemo(Any Collection Name you wish)->Create

2. Make a Request — To make a request, click on New->Request->GetUser(Any request name you wish)-
>Select the Collection you wish to save request in(Present in bottom of dialog box)->Save to Collection
Demo

3. By now, we have created our first request, now we need to pass different parameters in the request to
get the expected response.

4. In the “Enter Request URL” text box type : https://reqres.in/api/users?page=1

5. Click on “Send” Button

6. You should be able to see the below response in the Body section:

https://www.srijan.net/blog/manual-api-testing-using-postman 3/8
12/24/2019 Manual API Testing using Postman for Beginners

7. You should be delighted you have successfully tested your first API request.

Testing POST Requests


Now, suppose we need to create a user into a application that means we are sending data or feeding data
to an application. For these type of requests we use POST request. In POST request we send
data/parameter in the body of the request, and in response to that, API returns some data to us which
validates the user has been created. The response can either be a success message or the id of the new
user created and time when the user was created.

a. For making the first HTTP request(POST):

POST Request — To make a POST request, click on New->Request->CreateUser(Any request name you
wish)->Select the Collection you wish to save request in(Present in bottom of dialog box)->Save to
Collection Demo

1. From the Dropdown select POST

2. In the “Enter Request URL” text box, type : https://reqres.in/api/users

3. Click on Body Tab and select “Raw” radio button

4. In the text box, paste :

{
   "name": "morpheus",
   "job": "leader"
}

5. Click on Send button

6. User should see the below response:

https://www.srijan.net/blog/manual-api-testing-using-postman 4/8
12/24/2019 Manual API Testing using Postman for Beginners

7. Also, check for correct status code, in this case you should get : ‘Status:201 Created’

You have successfully tested your POST request too, similarly you can try your hands with PUT, PATCH,
DELETE etc.

1. Check for expected response.

2. Check for correct status code.

3. Check for Time (Response Time), it should be acceptable as per business.

4. Always perform negative tests to verify that the API doesn’t respond if data is tampered.

That’s all for this blog. Happy Testing!!

Stay tuned for my next blog on “Automation with Postman”

Discussion

https://www.srijan.net/blog/manual-api-testing-using-postman 5/8
12/24/2019 Manual API Testing using Postman for Beginners

0 Comments Srijan 
1 Login

 Recommend t Tweet f Share Sort by Best

Start the discussion…

LOG IN WITH
OR SIGN UP WITH DISQUS ?

Name

Be the first to comment.

ALSO ON SRIJAN

Why Decoupling Drupal with GatsbyJS is a Great Bluetooth GPS devices with Linux
Choice 1 comment • 5 months ago
2 comments • 5 months ago pooja kamboj — Hello ... gps devices for cars and ot
joshwaihi — You don't really talk about content freshness https://uploads.disquscdn.c... her vehicles .. check them
here? How well does Gatsby handle realtime publishing out here - https://garmincare.com
given it has to rebuild static views when your data sources

Building a code review process that works Content Syndication, Staging, and Synchronization
1 comment • 13 days ago with Drupal
sanjeev kumar — Hi 1 comment • 5 months ago
Nice post. Thank you for sharing such informative Anshita Shrivastava — Hi Akshita , very Nice article and
information with us. great Information . Just few things I wanted to understand .
Could you please give a brief about Setting up CMS

Articles you may also like

Integrate your Drupal website with CRM


applications for better ...
Drupal CRM integration with any third-party API helps
Drupal in better customer engagement. Check out some
CRM ...

BLOG • GAURAV MISHRA

https://www.srijan.net/blog/manual-api-testing-using-postman 6/8
12/24/2019 Manual API Testing using Postman for Beginners

Rolling out API Monetization for a


Philippines Telecom Giant with ...
With APIs offering dozens of ways to monetizing data,
Drupal, Planet Drupal,
here's how Srijan leveraged its expertise in building a
API Management
...

BLOG • KARTHIK D K

Harnessing Technology to Accelerate


Transformation in Pharma Industry
Healthcare & Life Pharma companies are running hard to keep up with
sciences, Digital the changing digital trends in the sector. Here’s how
Experience they are ...

BLOG • URVASHI MELWANI

Explore all projects

Write to us

How can we help you?

Name*

Email*

Phone*

Send me monthly newsletters covering blogs, projects, events, and


studio work.  Get in touch

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms Of Service apply. By submitting this form, you agree to our Privacy Policy.

https://www.srijan.net/blog/manual-api-testing-using-postman 7/8
12/24/2019 Manual API Testing using Postman for Beginners

See how our uniquely collaborative work


style, can help you redesign your business.
Contact us

Enter your email* Subscribe to our newsletter

Terms of Use • Privacy Policy • Cookie Policy

https://www.srijan.net/blog/manual-api-testing-using-postman 8/8

S-ar putea să vă placă și