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

How to use postman to execute API’s?

What is Postman?

Postman is a scalable API testing tool that quickly integrates into CI/CD pipeline. Postman is an API(Application programming Interface) platform for building and using API’s.

Postman simplifies each step of the API lifecycle and streamlines collaboration between developers to design, build, test and iterate their APIs, so that you can create better and faster API’s.

How to use Postman to execute APIs

Below is the Postman Workspace. Let’s explore the step by step process on How to use Postman and different features of the Postman tool!






  1. New - This is where you will create a new request, collection or environment.

  2. Import - This is used to import a collection or environment. There are options such as import from file, folder, link or paste raw text.

  3. Invite - Collaborate on a workspace by inviting team members.

  4. History - Past requests that you have sent will be displayed in History. This makes it easy to track actions that you have done before.

  5. Collections - Organize your test suite by creating collections. Each collection may have subfolders and multiple requests. A request or folder can also be duplicated as well.

  6. Request tab - This displays the title of the request you are working on. By default, “Untitled Request” would be displayed for requests without titles.

  7. HTTP Request - Clicking this would display a dropdown list of different requests such as GET, POST, COPY, DELETE, etc. In Postman API testing, the most commonly used requests are GET and POST.

  8. Send - Send the request to the Server

  9. Save - If there are changes to a request, clicking save is a must so that new changes will not be lost or overwritten.

10. Params -This is where you will write parameters needed for a request such as key values.

11. Authorization - In order to access APIs, proper authorization is needed. It may be in the form of a username and password bearer token, etc.

12. Headers – You can set headers such as content type JSON depending on the needs of the organization.

13. Body – This is where one can customize details in a request commonly used in POST requests.

14. Pre-request Script – These are scripts that will be executed before the request. Usually, pre-request scripts for the setting environment are used to ensure that tests will be run in the correct environment.

15. Tests – These are scripts executed during the request. It is important to have tests as it sets up checkpoints to verify if response status is ok, retrieved data is as expected and other tests.

16. HTTP Request – Clicking this would display a dropdown list of different requests such as GET, POST, COPY, DELETE, etc. In Postman API testing, the most commonly used requests are GET and POST.

17. Request URL – Also known as an endpoint, this is where you will identify the link to where the API will communicate.



Creating new Collection :





  • Click on the + to create a new collection

  • Click on Add a request to create a new HTTP request as shown above.

  • For each request you need to click New,

  • You can select the GET,POST,PUT,PATCH and DELETE requests and make it a collection

  • Select the request, give the input as shown in the below examples and click save and send. so that it will be added in the existing collection.



What is workspace in Postman:

Postman Workspaces allow you to organize your API work and collaborate with teammates. They act as a common working area where you can group your API projects together and use API builder to start defining APIs or generate API elements.



Working with GET Requests

Get requests are used to retrieve information from the given URL. There will be no changes done to the endpoint.

We will use the following URL for all examples:

https://reqres.in/

For GET:

https://reqres.in/api/users/2

In the workspace

  • Click new

  • Set your HTTP request to GET.

  • In the request URL field, input link

  • Click Save and click Send

  • You will see 200 OK Message

  • There should be 1 result in the body which indicates that your test has run successfully.






Working with POST Requests

We will use the following URL for all examples:

https://reqres.in/api/users


In the workspace

  • Click New

  • Set your HTTP request to POST.

  • In the request URL field, input link



  • Click on Body and click raw

  • Select JASON

  • In the body give the following snippet

{

"name": "morpheus",

"job": "leader"

}

  • Click Save and click Send

  • You will see 201 Created should be displayed

  • Posted data are showing up in the body as shown below.




*Note: Online Post request should have the correct format to ensure that requested data will be created. It is a good practice to use Get first to check the JSON format of the request.




Working with PUT Requests

We will use the following URL for all examples:

https://reqres.in/api/users/2

In the workspace

  • Click New

  • Set your HTTP request to PUT.

  • In the request URL field, input link

  • Click body and give the input as given below

{

"name": "morpheus",

"job": "zion resident"

}

  • Click raw and

  • Select JSON

  • Click Save and

  • Click Send

  • You should be able to see 200 OK message displayed with the given body as shown below in Pretty format.




Working with PATCH Requests:

We will use the following URL for all examples:

https://reqres.in/api/users/2

In the workspace

  • Click New

  • Set your HTTP request to PATCH.

  • In the request URL field, input link

  • Click body and give the input as given below

{

"name": "morpheus",

"job": "zion resident"

}

  • Click raw and select JSON

  • Click Save and

  • Click Send

  • You should be able to see 200OK message displayed with the given updated body as shown below.







Working with DELETE Requests:

We will use the following URL for all examples:

https://reqres.in/api/users/2

In the workspace

  • Click New

  • Set your HTTP request to PUT.

  • In the request URL field, input link

  • Click Save and

  • Click Send

  • You should be able to see 204 No content message displayed with the given empty body as shown below.






Conclusion:

Why Use a Postman?

With over 4 million users nowadays, Postman Software has become a tool of choice for the following reasons:

  1. Accessibility – One can easily access files anytime, anywhere as long as a Postman application is installed on the computer.

  2. Use of Collections – Organizing test suites with Postman lets users create collections for their Postman API calls. Used to create subfolders and multiple requests.

  3. Collaboration – A direct link can also be used to share collections. Collections and environments can be imported or exported making it easy to share files.

  4. Creating Environments – Having multiple environments avoids repetition of tests as one can use the same collection but for a different environment.

  5. Creation of Tests – Test checkpoints such as verifying for successful HTTP response status can be added to each Postman API calls which help in test coverage.

  6. Automation Testing – Collection Runner or Newman, tests can be run in multiple iterations saving time for repetitive tests.

  7. Debugging – Postman console helps to check what data has been retrieved making it easy to debug tests.

  8. Continuous Integration– Postman has the ability to support continuous integration, development practices are maintained.






99 views0 comments

Recent Posts

See All
bottom of page