golden nugget online

Learn Postman Step By Step - Import Via cURL, HAR

Introduction

In this step-by-step article series next, we are going to learn about the Import features of the postman. Before going to learn about the environments, please read the previous article of this series for a better understanding:

This article covers the following topics,

  • What is Import & its features?
  • Importing via cURL
  • Importing via HAR

What is Import & its features?

One of the cool features provided by Postman is import. With the help of import functionality, we can directly import our file, copy data from the browser to create a request, collections, etc. Below is the screenshot:

Postman

In the above screenshot, you can see there are various options or formats available for import functionality as below,

  • OpenAPI
  • GraphQL
  • cURL
  • WSDL
  • HAR
  • etc.

Let's see how we can use these import options with an example.

Importing via cURL

It is the most commonly used command-line tool and library to transfer the data with Urls(), but how to get that cURL request to pass into the postman import? When we import via cURL then it creates a request with that import.

Following are the steps to get the cURL request from the browser and import it into the postman:

Step 1

Make a post or get a request from the browser.

Step 2

Press F12 or right and 'Inspect', it will open the DevTools for the page and go to the 'Network' tab as below:

Postman

Step 3

Next, right-click on your request name here in my case 'weatherforecast', and select 'Copy' then select the 'Copy as cURL(cmd)' option as below:

Step 4

Open the Postman and select the 'Import' option next to 'New', it opens up the pop-up as below:

Postman

Step 5

Select the 'Raw text' tab and paste the copied data and click on the 'Continue' button as below:

Postman

Step 6

Next, It will show you the details like 'Name, Format, and Import As' then click on the 'Import' button as below:

Postman

In the above screenshot, you can see the column name 'Import As' and its value is 'Request' that is nothing but it is going to create the request with this data.

Step 7

Once you click on the 'Import' button it will create the request for you with all the data we have used during the import like request URL, headers, parameters passed any, etc. as below:

Postman

Let's cross-check with our original request as below,

Postman

If you compare both the header values it's the same as browser request headers.

Step 8

Click on the 'Send' request button and you will get a response as below:

Postman

Importing via HAR

HAR stands for HTTP-Archive. It is a JSON-based format generated by the HTTP-based tools included by most web browsers. It is mostly used for troubleshooting and detecting the issues, related to page rendering and performance. When we import via HAR then it creates a collection and under that collection, the request is created with that import.

Following are the steps to get the HAR request from the browser and import it into the postman:

Step 1

Please follow the initial same step as we did in the previous section and select the option 'Save all as HAR with content' then save that file as below:

It will save the HAR content file with extension as '.har' as below:

Step 2

Next, Open the postman and click on the 'Import' open and select 'HAR' as the import option as below:

Postman

Then, it will open the file selection dialogue and select the previously saved '.har' file.

Step 3

After selecting the file you will see the details such as 'Name, Format, and Import As, Show advance settings' as below:

 Postman

In the pop-up, you can see the format as 'HAR' and the import as 'Collection', when we expand the 'Show advance settings', these settings are used for creating the collection with this import as below:

Postman

Step 4

Next, click on the 'Import' button with default settings and you will see the created collection, under that your request is as below:

Here you can see, that the collection is created as 'localhost:60111' and under that separate section is there for 'localhost:60111/weatherforecast'. It combines all the requests related to the 'weatherforecast' section such as 'GET, POST, PUT, DELETE, etc.'.

Step 5

Click on the collection name that is 'localhost:60111' and right side you can see details about the collection as below:

Postman

The details such as 'Authorization, Pre-request Script, Test and Variables' and the collection description in 'Documentation' such as 'HAR To Postman Generated Collection'.

Step 6

Click on the next section which is 'localhost:60111/weatherforecast' and right side you can see details about the collection as below,

Postman

We are going to explore about the collection in upcoming articles stay tuned.

Step 7

Click on that 'GET' request and see the right side section as below:

Postman

Step 8

Finally, click on the 'Send' button and you will get the result back as below:

Postman

Stay tuned to learn golden nugget online things about Postman….

Conclusion

In this article, we learned about what is import and its feature and Import via cURL and Import via HAR. If you have any suggestions or queries regarding this article, please contact me.

“Learn It, Share it.”