Importing Api List From Swagger And Introduction To Collection In Postman

Introduction

Postman is open source, free to install in your system and is used to test APIs. Using Postman, you can test any type of Services, controller, or web application after setting your configuration.

How to use postman?


According to the image, you need to follow the given points.

  • Select request methods e.g. GET, POST, PUT, DELETE...etc.according your endpoint request.
  • Enter complete Endpoint with query string value (if any) e.g. ApiUrl
  • Enter access token (if any) and set Content -Type =>” application/json”. For details, please refer to the below screenshot.

  •  
  • If request method is POST/PUT/DELETE, you have to set BODY panel. In case of GET, it will be hidden.
  • Click=>BODY panel=>check raw=>type json payload e.g.
    1. "CustomFieldDonationAnswers": [{  
    2.     "CustomFieldGuid""string",  
    3.     "FieldAnswer": {}  
    4. }],
    For details, please refer to the below screenshot


  • Click=>SEND, thereafter, you can see response data in the bottom panel in the form of JSON data. 

How do we create collection in Postman?

Using Postman, you can categorize requests with all details (parameter, access token, endpoint, etc...) in the folder. Collection can be imported in Postman for next time. Follow the simple 2-3 steps to create collection.

Step 1

Once the entire configuration for Postman is set, press ctrl+S to get the new window open. In new window, we need to set these things as given below.

  • Request Name e.g. “Create Donation”.
  • Request description (optional) e.g. “To create new donation with externalID…”.
  • Create collection name e.g. “Application_Integration”. If already created, we can select any.
  • Click on ‘Save’ button, thereafter we can see folder in left panel. For details, please refer to the below screenshot


After clicking on ‘Save button, you can see in the left panel the endpoint is listed. We can save multiple endpoints in a single folder with request details.

If we have already created folder and we want to add new endpoint, just follow the above steps and select “save an existing collection” picklist, and we can see all existing folders and select any.

Step 2

To export and save collection on local drive, please refer to the below screenshot.


Click on “Export”. A new popup will be opened as per the below screenshot.


User can choose the option and click on “Export” button. After that, select path in your local drive and save. You can see collection has been saved on your local drive in the .json file.

How do we import collection?

If we want to import collection in Postman from local drive, just follow these steps.

Open Postman=>Click on “Import” button. Please refer to the below screenshot.


After clicking on "Import" button, a new popup will be opened to select source type. Please refer to the below screenshot.


Select “import file” tab and click on “Choose file” from local drive.Thereafter, you can see the collection in left panel with complete details.

How do we import endpoint list from swagger?

In this part, we will go through an example and steps to import endpoints list from swagger with details.

As we know swagger contains endpoints list in json format. For example you can verify the URL “***********************”.


  • Copy swagger URL and go to postman.Open postman=>click on Import”a new popup window will be open. For details please refer to the below screenshot


  • Select “Import from link” tab paste swagger URL in textbox.
  • Click on Import.
  • Now, you are able to see all endpoints from all folders as available on postman. After that, postman will look as shown in the below screenshot.


After importing from swagger, all endpoints are available in postman with remarks, endpoints, method( GET,POST….), and header value except payload

Now, you need to set payload inside Body tab=>raw, because Microsoft doesn’t allow importing payload from swagger. 

Other referenced link.


Similar Articles