Tuesday 12 December 2023

Postman - Building API Requests and Key Features

Introduction: Postman is an essential tool for developers, enabling them to streamline API development and testing processes. With Postman, you can easily build, test, and document API requests, while taking advantage of its extensive features to enhance collaboration and automation within your development projects.

Step 1: How to install the Postman
There are two ways to run Postman:

    1. As a standard app or
    2. Directly in the browser

  • The standalone app is available for Windows, macOS, and Linux.
  • Postman Web: Works on any browser, use Desktop Agent if needed.
  • Do not use the Google Chrome extension as this is deprecated and no longer updated.

Step 2: How to create our own workspaces.

Why we need a workspace.
In Postman, "workspaces" refer to collaborative environments that allow teams to work  together on API-related projects. Workspaces are shared areas where team members can create, organize, and manage API collections, environments, documentation, and other assets. They provide a structured and collaborative space for multiple team members to collaborate on API development and testing, ensuring that everyone has access to the same resources and can work on projects efficiently. Workspaces are particularly useful for organizations that want to centralize their API-related work and promote collaboration among team members.

  • Steps Creation of Workspace:-

       

       

Step 3: API request with Postman

  • The API we are using uses the HTTPS protocol.
  • HTTP stands for Secure Hypertext Transfer Protocol.
  • HTTP ensures that the connection is encrypted.
  • All APIs should use HTTPS.
  • From our point of view, HTTP and HTTPS are the same.
  1. The HTTP request message will contain:
    • URL (address)
    • Request method (GET, POST, PUT, PATCH, DELETE)
    • Headers (User-Agent: Postman)
    • Body

  • In the URL we are using HTTPS protocol. This HTTPS stands for Hypertext Transfer
Protocol Secure.

Step 4: How to add Postman collection and Variable.

  • How to save the request?

  • You can save requests so that you can reuse them later on.
  • All requests need to be added to a Postman collection.
  • We are storing the base address of the API in a collection variable called baseUrl

  • Our saved baseUrl will be displayed as {{baseUrl}} in the address bar.

  • How to set variables manually?

Step 5: How to use Query Parameters in Postman

What are Query parameters?

Query parameters in Postman are key-value pairs that you can include in the URL when making an API request. These parameters are used to filter, sort, or modify the data you retrieve from the API. Query parameters are typically added to the end of the URL after a question mark (?), and multiple parameters are separated by ampersand (&)

  •  example of a URL with query parameters in Postman:

  • The format is key=value

Step 6: How to use Path Variables in Postman

What are Path Variables in Postman? 

Path variables in Postman are dynamic values within the URL path of an API request that allow you to send variable data as part of the URL. They are typically used to retrieve specific resources or perform actions on those resources by including them directly in the URL path
  •  Here's an example of a declaration of a path variable.

Step 7: Why we are using Postman and where we can’t use Postman.

  • Postman is mainly used for communicating with API.
  • Limitation:
    • User Interaction
    • Performance Testing
    • Security Testing.

Step 8: How to write test class inside Postman.

Step 9: How to see response data in the Console in JS format

Step 10: How to set global Variable in Postman.

   Why do we need a global variable?
  • In Postman, global variables are needed to store and share data across multiple requests or scripts in a collection or project, ensuring consistency, reusability, and easier maintenance of shared values, such as API endpoints, authentication tokens, or dynamic data, for efficient and organized API testing and development.
  • How to set: -
  • Step 1

  • Step 2

Step 11: How to create a Collection in Postman and how to run all
methods at a time.

Output:

  • It will show full collection results at a time

Step 12: Monitors in Postman.

Postman Monitors are a feature in Postman that automates the testing and monitoring of APIs. They allow you to schedule and run collections of API requests at specified intervals, providing automated testing, performance assessment, and notifications for your APIs, which is particularly valuable in a continuous integration and delivery (CI/CD) environment.

Thank You

2 comments:

  1. Thank you so much for the information. Besides, if you need any IT services, then ITFux is here to help. Get seamless support from ITFUX24's Laptop reparatur Frankfurt services, plus a fantastic 15% discount on your initial service.

    ReplyDelete