top of page
hand-businesswoman-touching-hand-artificial-intelligence-meaning-technology-connection-go-

Jump Start Guide : REST API Automation testing through Postman


Before moving forward , please visit the below link to go over the documentation of Books API that we will be using to understand the concepts of Postman API automation

Concepts that is covered

  • Common Acronyms of a API

  • Common HTTP methods in Postman

  • HTTP responses(status code)

  • Key Concepts of Postman

  • Scripts and Tests in Postman



 

Common Acronyms of a API

  • endpoint

  • HTTP request

  • HTTP response

  • Headers

  • URI Param

  • Query Param

  • Body

  • HTTP method

  • HTTP response

Common HTTP methods in Postman

  • GET – to get (read) data , either entire list of data or based on a key

  • POST – to create new data.

  • PUT / PATCH – to update data that already exists.

  • DELETE – to delete data based on a unique key.

  • OPTIONS – to get a full description of API methods available on the service.


HTTP responses(status code)

  • 1xx informational response- the request was received and is continuing in the process.

  • 2xx successful- the request was successfully received, understood, and accepted by the server. 200(OK) – It indicates that the API successfully carried out the client’s request. This is usually returned for an existing record. 201(created) – The request is sent and it involves creating a new resource and is successful. 204(No content) – The request is successfully sent and it doesn’t send back the response messages. Usually used for Delete operation

  • 3xx redirection - the request is incomplete and some actions need to be taken to complete it. 302(redirect) - It indicates that the actual API was not called and redirected before reaching server.

  • 4xx client error - the request contains bad syntax, or business logic error. 400(Bad request)– The server will not process the request due to the error from the client’s end. 401(Unauthorized)– 401 indicates that the client tried to operate on a protected resource and is unauthorized. 403(Forbidden)– The client sends the correct request but the server refuses to give the response. 404(Not found)– The requested resource could not be identified at present and may be available in the future. 405(Method not allowed)– The client uses an invalid request method that the resource doesn’t allow. 422(Business Logic Error) - The server processed this request but had to return an error because of business validation failure.

  • 5xx server error- the server failed to fulfill a valid request. 500(Internal server error)– This happens when the server faces an unexpected condition. 503(Unreachable) - The server is not reachable. 504(Timeout) - The server did not respond back before the expected time.


Key Concepts of Postman

  • Collections - Organizing of the requests for a given project, A collection is essentially a folder where you can store multiple requests to various endpoints. We can import an existing collection if it is already structured and documented, or we could create it from scratch by structuring all common request into one folder. This will be helpful for sharing data and running the request in a particular order. Below is an screen shot of how an collection would be organized



  • Data Sharing - sharing data between request is an important and essential requirement for automation of API tests, Some of the examples include - Sharing the Auth token between requests. - Sharing the same header values between the requests. Below is an example of how we share basic auth across the requests in a collection Click the 3 dots on the collection name and click edit , add the basic auth with the user name and password

Now for the tests that require this auth method in the collection , choose the ‘Inherit auth from parent’ on the Authorization tab.


  • Variables - enable you to store and reuse values in Postman. By storing a value as a variable, you can reference it throughout your collections, environments, requests, and test scripts. The lowest variable scope is Local, and then next is Data, Environment, Collection, and the higest one is Global. Local Variables These are temporary variables and its scope is only in the environment they were created in. When you change the environment, the variable will stop its access. Collection Variables its scope is available for all the requests in a collection. Environment Variables its scope is available in a single environment . They are bound to a specified environment used to execute the request. Global Variables its scope is global. Through global variables, we can access data between collections, test scripts, requests, and environments. Data Variables Data variables come from external CSV and JSON files to define data.

screenshots of the various variable below

Collection Variable

Environment / Global Variable


  • Pre-request Scripts - When you need to create some data or variables before you run a test. In that case, you can use the pre-request scripts tab. You can write java script business logic that are needed to be performed before executing the test. Some example include like schema validation etc. You can store data into variable or get data from variables.



  • Tests - Test scripts in Postman are written in JavaScript, Postman has some built in code snippets, You can write java script business logic that are needed to be performed after executing the test. Some example include like schema validation etc. Asserting the responses etc You can store data into variable or get data from variables.


Hope this blog get you started with REST API automation Test using Postman. Its better to start rather than just thinking !!! Happy Learning

60 views0 comments

Recent Posts

See All

Beginner Friendly Java String Interview Questions

Hello Everyone! Welcome to the second section of the Java Strings blog. Here are some interesting coding questions that has been solved with different methods and approaches. “Better late than never!”

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page