Recognized by Clutch.co as a top-rated Mobile App Development Company.
folio3-mobile
US 408 365 4638
START YOUR PROJECT
  • Solutions
    • Apps Discovery Services
    • Team Augmentation
    • Enterprise
    • AR/VR
    • IoT
    • Wearables
    • Field Sales
    • On Demand Apps
  • Industries
    • Retail
    • Agriculture
    • Healthcare
    • Pharmaceutical & Life Sciences
    • Manufacturing
    • Automotive
    • Logistics
    • Education
  • Technologies
    • Native Mobile Apps
      • iOS
      • Android
    • Cross Platform Apps
      • React Native
      • Flutter
      • Ionic
      • Xamarin
      • NativeScript
      • Sencha
  • Portfolio
  • Blog
  • Contact Us
  • Solutions
    • Apps Discovery Services
    • Team Augmentation
    • Enterprise
    • AR/VR
    • IoT
    • Wearables
    • Field Sales
    • On Demand Apps
  • Industries
    • Retail
    • Agriculture
    • Healthcare
    • Pharmaceutical & Life Sciences
    • Manufacturing
    • Automotive
    • Logistics
    • Education
  • Technologies
    • Native Mobile Apps
      • iOS
      • Android
    • Cross Platform Apps
      • React Native
      • Flutter
      • Ionic
      • Xamarin
      • NativeScript
      • Sencha
  • Portfolio
  • Blog
  • Contact Us

Optimize your development timelines using Mocking APIs with Postman

Published by: Muhammad Saqlain | July 11, 2019
SCROLL AND BE AMAZED!
Home > Blog > Optimize your development timelines using Mocking APIs with Postman

We have already discussed in an earlier post what Postman is and how you can achieve Automation & create beautiful web-viewable documentation using Postman. Let’s get started and learn how we can test our APIs by mocking using Postman.

What is Mocking?

Mocking is one particular technique to allow testing of a unit of code without being reliant upon dependencies. In general, what differentiates mocking from other methods is that mock objects used to replace code dependencies will allow expectations to be set. In Short, Mocking is creating objects that simulate the behavior of real objects.

What is the goal?

Delays on the front or back-end make it difficult for dependent teams to complete their work efficiently. Postman’s mock servers can alleviate those delays in the development process. Developers can view potential responses, without spinning up a back end.

Ergo, rapid development!

Why do we want to do this?

By creating a mock collection in the earlier phases of API development stimulate clear communication among team members and aligns their expectations.

As a result, all teams in the development process can work in parallel and dependent teams experience fewer delays.

What is a Mock Server?

A mock server is just a fake server that is simulated to work as a real server so that we can test our APIs and check the response or errors. Postman lets you create two types of mock servers: private and public.

Private mock servers require users to add a Postman API key in the request header. x-api-key:<your postman API key>

Public mock servers are accessible to anyone. When you share a public mock server, users don’t need to add a Postman API key.

How to create a mock server using Postman?

You can create a mock by click on New Button in Header toolbar or when you launch postman you can see an option on launch screen as well.

We will follow the following steps to integrate mock into your existing collection and use Postman Echo service to make sample API calls. :

  1. Sending a request (R1)
  2. Saving the request (R1) to a collection (C1)
  3. Saving the request R1’s response as an example (P1)
  4. Creating a mock (M1) for the collection (C1)
  5. Sending a request using the mock server (M1)
  6. Using query params to match

Step 1: Sending a request (R1)

Using the Postman app, send a GET request to the URL https://postman-echo.com/get?test=123. The response can be seen in the image below.

Step 2: Saving the request (R1) to a collection (C1)

Hit the Save button to open the SAVE REQUEST modal. You can save a request to an existing collection, or save it to a new collection. Let’s create our new collection called C1 which will be accessible in the Collections tab.

Step 3: Saving the request R1’s response as an example (P1)

Save an example response from the request R1 by hitting the Save Response button.

This takes us to the Examples screen which can be used to save the request response as an example. Let’s call this example P1.

The request method, URL, and status code are crucial in determining which responses will be returned by the mock we will create. Verify these elements are all as desired, and hit the Save Example button. Hit the back arrow in the top left to return to the request builder, and we can now see the example we created in the top right, added to the request.

Step 4: Creating a mock (M1) for the collection (C1)

From the Postman app, click on the arrow (▸) next to the collection C1 to expand the details view. Under the Mocks tab, click on Create a Mock server button to open the MOCK COLLECTION modal. Here, you can choose a corresponding environment to include in your mock or select the type of mock server either private or by default public.

Once you mock the collection, it will be visible under the Mocks tab of the collection details view. You can also see the mock URL we will need for the next step.

Step 5: Sending a request using the mock server (M1)

Now that we have created our mock M1, let’s try sending a request to this mock endpoint. Copy the mock URL from the mock we created in the previous step, and paste it into a new request.

Responses returned by the mock service are entirely dependent on your saved examples and the included URL and request method type. We have a saved example with the path /get and the request method GET. So sending a GET request to the/get will return a proper response we are looking for.

Step 6: Using query params to match

Postman’s Mock server functionality is enhanced to return different responses based on matching request query params. Postman’s Mock server looks at the query params while matching requests to the examples. Which means if you have examples that differ only in query params and want to mock different responses for different query params on the same request path, Postman’s mock server will return the exact response matching that request path and the corresponding query params.

Example as illustrated by Postman Team

And we’re done! We have walked through how to create a collection, save requests, save examples, create a mock, and use a mock.

Postman account gives you a limited number of free mock server calls per month. You can check your usage limits in the Postman API or in the account usage page.


About msaqlain

A hardworking and dedicated individual, determined on the road to success, ever ready to take on challenges and accomplish what I set out to achieve.

Newsletter

Search

Archives

  • December 2023
  • April 2023
  • March 2023
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • October 2021
  • September 2021
  • May 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • May 2019

Recent Posts

  • Exploring Flutter Navigation: From Basics to Advanced Routes
  • Web UI Test Automation with Pytest-BDD
  • How to fix IOS compass calibration issues
  • Testing Android Applications With Perfect Coverage
  • How to use useRef hook efficiently? – React

Tags

  • android
  • angular-state-management
  • Automation
  • Compass
  • cross-platform
  • css
  • development
  • firebase
  • hooks
  • ios
  • learn-ngrx
  • ngrx-beginner
  • ngrx/store
  • QA
  • react-native
  • reactjs
  • scss
  • stylesheet
  • styling
  • Testing
  • Test Script
  • UI-UX

Newsletter

Newsletter

Post navigation

Previous Why you should start adopting Automated Testing today!
Next How to deploy a microservice architecture using PM2
Schedule an Appointment with our Mobile App Development Expert
Footer Menu
  • Company
    • About Us
    • Portfolio
    • Blog
    • Careers
    • Contact Us
  • Solutions
    • Apps Discovery Services
    • Team Augmentation
    • Enterprise App Development
    • AR/VR Application Development
    • IoT Application Development
    • Wearables Apps Development
    • Field Sales
    • On-Demand Apps Development
  • Technologies
    • iOS
    • Android
    • React Native
    • Flutter
    • Ionic
    • Xamarin
    • NativeScript
    • HTML5
    • Sencha
  • Industries
    • Retail
    • Agriculture
    • Healthcare
    • Pharmaceutical
    • Manufacturing
    • Automotive
    • Logistics
    • Education

US Office

Belmont, California – 1301 Shoreway Road, Suite 160, Belmont, CA 94002

Pleasanton, California – 6701 Koll Center Parkway, #250 Pleasanton, CA 94566

Tel: +1 408 365 4638
Support: +1 (408) 512 1812

Mexico Office

Amado Nervo #2200, Edificio Esfera 1 piso 4, Col. Jardines del Sol, CP. 45050, Zapopan, Jalisco, Mexico

Bulgaria Office

49 Bacho Kiro Street, Sofia, 1000, Bulgaria

Canada Office​

895 Don Mills Road, Two Morneau Shepell Centre, Suite 900, Toronto, Ontario, M3C 1W3, Canada

UK Office

Export House, Cawsey Way, Woking Surrey, GU21 6QX

Tel: +44 (0) 14 8361 6611

UAE Office

Dubai, UAE – Dubai Internet City, 1st Floor, Building Number 12, Premises ED 29, Dubai, UAE

Tel: +971-55-6540154
Tel: +971-04-2505173

Pakistan Office

Folio3 Tower, Plot 26, Block B, SMCH Society, Main Shahrah-e-Faisal, Karachi.

First Floor, Blue Mall 8-R, MM Alam Road Gulberg III, Lahore.

Tel: +92-21-3432 3721-4 

© 2025, Folio3 Software Inc., All rights reserved.

  • Privacy policy and terms of use
  • Cookie Policy
Follow us on
Facebook-f Linkedin-in Instagram

Get a free app audit

[contact-form-7 id="3548" title="Float Banner Form"]