Table of contents
1.
Introduction
2.
Examples in Postman
2.1.
Adding an example
2.2.
Editing an example
2.3.
Duplicating an example
2.4.
Deleting an example
2.5.
Use cases
3.
Certificates in Postman
3.1.
Managing Certificates
3.2.
Using a Certificate
4.
Client Code in Postman
5.
Frequently Asked Questions
5.1.
What are the ways in which you can use an example?
5.2.
Give some examples of the supported frameworks for Code Snippet Generation.
5.3.
Which range of plans does Postman offer?
6.
Conclusion
Last Updated: Mar 27, 2024

What are examples in Postman?

Author Rupal Saluja
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Do you know Postman was started as a side project in 2012? A Software Engineer Mr. Abhinav Asthana whose aim was to simplify API testing, started Postman’s development while working at the Bangalore office of Yahoo.

Initially, he was the only developer handling this project launched as a free app in Chrome Web Store. But as its usage grew exponentially, he recruited his colleagues to create an advanced version of Postman. Now, these three co-founders cum developers run this association. 

Postman logo

Their products include API repository, API builder, Intelligence, Workspaces, API Client, API Design, API Documentation, API Testing, Mock Servers, and API Detection. In this blog, we will learn about how to specify examples, how to work with certificates, and how to generate Client Code in Postman.

Introductory Image

Examples in Postman

When you are familiar with how to visualize API, don’t you think you require something that confirms that your endpoints are in action and provide extra information on how exactly requests and responses work?

Concerning Postman, an example is a tightly-coupled request and response pair, that is, each example is made up of two parts, which are the Request and Response parts. The Request part consists of methods, URLs, parameters, headers, and body. The Response part consists of Status Code, Body, and Headers.

An example is created when you add them to requests in collections. Note that one request can have multiple examples. In such cases, examples are useful to illustrate different ways an endpoint will respond to a request.

Examples in Postman

Adding an example

We have already learned that an example is always associated with a request in a collection. There are two ways in which you can add an example. 

🌻 The first way is to add an example quickly to a request, you need to send the request and then save the response. 

🌻 The second way is to add an example manually after defining a custom response. 

After you add an example using either method, you can edit it anytime to make changes and generate a custom response.

Editing an example

It is implied that examples are stored in a collection with their requests if examples are associated with an example every time. An example can be edited anytime by removing the sensitive tokens, changing the status code, or making any other necessary adjustments.

To edit an example, you need to follow the steps mentioned in the image given below.

editing an example

Duplicating an example

When you read duplicate, the first thing that comes to mind is a copy or replica. Even with reference to the Postman, this meaning stays the same. By duplicating an example, we mean to quickly add a new example using an existing one as the base for it. A copied example can be edited by changing the name, status code, or any other part of the response or request, as per the requirement.

To duplicate an example, you need to follow the steps mentioned in the image below.

duplicating an example

Deleting an example

When we say deleting an example, it means removing it from the collection as well as from the associated API documentation. Note that once the example has been deleted, any mock servers set up by you would no longer be able to use that example to return a response.

To delete an example, you need to follow the steps mentioned in the image below.

various steps involved in deleting an example in Postman

Use cases

For every collection you create, documentation is created automatically in the Postman. The generated documentation can create any number of examples that you have added to that documentation previously. In case you have edited an example, the documentation is also updated automatically.

 An example is always needed to provide extra information, additional details, and clarification for your API and help the team to collaborate on API Development. The team includes front-end developers, back-end developers, and testers who work in parallel using the examples.

Certificates in Postman

When sending requests, you can add and manage certificates in Postman to enable the authentication process. You will need a client certificate to Postman in order to connect to an API that uses Mutual TLS (mTLS).

sample certificate

Mutual TLS an authentication mechanism that demands certificates required by both the client and the server for their identity confirmation. Once the certificate has been authenticated, an encrypted connection is established.

Managing Certificates

By the term Managing Certificates, we mean viewing installed certificates, adding new certificates, or removing the installed certificates. Every process will be discussed in this blog further.

You need to select the Setting icon in the header and move to Settings. Then, Click on the Certificates Tab.

Certificates in postman

Adding CA Certificates

To avoid self-signed certificate errors while sending requests, a Custom Certificate is added to the Postman. To add such certificates, you must turn on the Toggle next to the CA Certificates in the Certificates Tab. After that, select the PEM file you want to use for your CA Certificate.

adding CA certificates

Adding CA Certificates

Adding Client Certificates

You need to add the Client Certificate to the Postman to send requests to an API that uses mTLS authentication. To add Client Certificates, you need to follow the steps mentioned below.

  1. Under the Certificates Tab, select Add Certificate from the Client Certificates menu.
  2. Now, you need to enter the Host domain for the certificate.
  3. After that, add a custom port number to form an association with the domain. This step is optional. If a custom port has not been specified, the Postman uses the default HTTPS port.
  4. Now, you will be given two options. Either select the CRT file and the key for your certificate or select the PFX file for your certificate.
  5. If, at the time of client certificate generation, you used the Passphrase, enter it in the box. If no, leave that field blank.
  6. Select Add.

 

You will see a client certificate added with the specified parameters.

Editing a Certificate

There is no such option available using which you can edit a certificate. To make any changes, you need to remove that certificate first, then generate a new certificate and add it to the Postman.

Removing a Certificate

You can remove a certificate anytime you feel it is no longer needed for sending requests from Postman. To remove any certificate, you need to follow a very simple procedure. Select the remove icon next to the certificate and then confirm Remove.

Using a Certificate

After a Client Certificate has been added, there are no extra steps required to use that certificate in Postman. When you generate an HTTPS request for a configured domain, a Client Certificate is sent automatically with the request by the Postman. An OpenSSL handle is used for sending the certificate.

Using a certificate

Confirming a Certificate was sent

You can confirm that a certificate was sent using the Postman Console. To open the Postman Console, select the Console option in the Postman footer. After that, send a request. You can refer to the example below for a better understanding.

sample confirmation screen

Confirmation Screen

Viewing Certificate Details

You can always view additional certificate details in the response pane. If a request was sent using HTTPS, the network icon in the Postman Footer would include a padlock.

You can always hover over the network icon in case you want to view information about the certificate which was sent with the request, or any warnings or errors, for example, in the case of self-signed and error certificates.

Troubleshooting Certificate Errors

In case of certificate verification failure while sending a request, an error message will be displayed in the response pane of the Postman. To fix the error, turn off the SSL verification for that request. To do the above, follow the steps mentioned below.

  1. Open the request, and from the menu, select the Setting Tab.
  2. After that, select Enable SSL Certificate Verification to turn off this setting.
  3. Now, send the request again.

 

After you have turned off the SSL verification, you can hover over the network icon of the response pane in case you need details about any certificate errors or warnings.

sample troubleshooting certificate errors

Troubleshooting certificate errors

Client Code in Postman

The Postman can convert an API request into a code snippet. You will always have the option to choose the programming language or framework you want to use. This generated front-end code snippet can be used in your front-end applications.

client code

To generate a code snippet, follow the steps mentioned below.

  1. Firstly, you need to open the request you want to use for a code snippet. Then, from the right panel, select the code icon.
  2. Select any framework or language as per your need from the list of allowed options.
  3. Now, copy the code snippet given below to your clipboard.
var settings= {
     “url” : “https://randomuser.me/api/”,
      “method” : “GET”,
      “timeout” : 0,
};


$.ajax(settings).done(function
      (response) {
    console.log(response):
});

 

4. For any other configuration options, such as indentation type and count, select the settings icon next to the dropdown list. The settings there may vary depending on the chosen language or framework.

Frequently Asked Questions

What are the ways in which you can use an example?

The various ways in which an example can be used are given below.

  • Examples can be used by developers and testers to understand better how an endpoint function.
  • Examples are used to set up mock servers. This way, developers can start writing code against the client’s API before it is complete.
  • Examples can be added to API’s public documentation, which will help anyone around the globe.

Give some examples of the supported frameworks for Code Snippet Generation.

Some examples of the supported frameworks, along with their respective language, are mentioned in the table below.

Language 

Supported Frameworks

C LibCurl
C# RestSharp
Dart Dart
HTTP (Raw HTTP Request)
Java OkHttp, Unirest
JavaScript Fetch, jQuery, XHR
NodeJS Axios, Native, Request, Unirest
PHP cURL, Guzzle, Http_Request2, pecl_http
Python http.client (Python 3), Requests
R httr, RCurl

Which range of plans does Postman offer?

The range of plans that Postman offers ranges from a free edition to an enterprise edition. The free edition is for small projects, and the enterprise edition attracts larger projects. Postman aims to serve thousands of developers by offering custom domains, reporting, governance, analytics, and enterprise integrations.

Conclusion

In this article, we have extensively discussed what examples are and ways to manage examples in Postman. We have also discussed what Certificates are in Postman and how to manage and use a certificate. We also saw what Client Code is and how to generate one using Postman.

We hope that this blog has helped you enhance your knowledge regarding the topic of Visualizing Responses. If you want to learn more about Postman, you can check our articles on PostmanBrief Introduction to PostmanAPI Development in Postman, and Publishing an API in Postman.

For peeps who want to learn more about APIs, you can refer to our blog on Web TestingAPI TestingAPIWeb Application Testing Tools, or API Reference, you can click on the respective links. Enroll in our courses, go for mock tests, solve problems available, and interview puzzles. Also, you can focus on interview stuff- interview experiences and an interview bundle for placement preparations. Do upvote our blog to help other ninjas grow.

Thankyou

Happy Coding!

Live masterclass