Create Your Mock Server using Postman
Build your own Mock Servers using postman & start working against a service API even before the service is available.
Introduction
Mock Servers allow you to simulate your API data. When Mock Server receives a request, it matches the request against active expectations that have been configured.
If an API or service is not yet fully developed they can mock the API allowing any team who is using the service to start work without being delayed. These mock servers can be built with a tool called postman.
Creating the Mock Server
You can create mock servers from an existing postman collection, or Postman will create a new collection for your mock server. You can create a new mock from scratch also. Today lets we can build a simple mock server from scratch.
Open postman tool
Click on the mock servers section in the sidebar
- Create a new collection and add an initial request
Now, you will be able to see a new tab asking for some basic information about the server. If you create a new API to mock, you will select a request method and enter the request path, response code, and response body or else use an existing collection to mock.
Configuring mock server details
To configure your new mock server, give it a name. You can select an optional environment to have your mock sever use environment variables. You can also configure a delay before the mock server sends responses to simulate network delays.
After you finish selecting configuration options, select Create Mock Server. Postman displays the details you need to use the mock server.
Making requests to mock servers
Use the mock server's URL to make calls to the mock server. Select Mock Servers in the sidebar, select a mock server, and select Copy Mock URL.
Now you use this mock server to build your frontend application. You can use the mock call log to troubleshoot your requests to mock servers. In the case of a service outage, you will get a 502, 503, or 504 response.
Conclusion
Please share & like Feel free to share your inputs in the comments for improvements.Share what tool do you use to creating a simple mock API for testing