Setting up the mock server in Postman

Prathap
3 min readNov 13, 2020

We can create a mock server in Postman and make requests that return the mocked data defined if no production API is ready or do not want to run the API requests against real data.

We can simulate the behavior of real API by adding a mock server to the collection and adding examples to the requests. Postman will match the request configuration to the examples saved for the request and respond with the data added to the example.

Steps to create a mock server

  1. Open the Postman and click on ‘+’ to create a new request

2. Enter postman-echo.com/get in the request URL section and click Send

3. Click on Save to save the request to the collection.

4. Click on the Create Collection button to create a collection to save the request

5. Enter a name for Collection and click on the right symbol.

6. Click on Save to Mock API Server Demo button ( Note: Mock API Server Demo si the collection name I have given and this may change if you provide a different name for Collection)

7. Click on Examples >> Add Example

8. Provide the name for Example response, change the response by adding “name”: “Mock API Server Demo” (this can be anything), and then click the Save Example button to save the response.

9. Now go to the collections, select the collection we have created in previous steps and click on the arrow button

10. Click on Mocks

11. Click on Create a mock server

12. Give your mock a name, leave the default version selected, and the environment empty. Click Create Mock Server.

13. Copy the mock URL and click Close

14. Go back into the Example response. Replace postman-echo.com with the mock URL—keeping the /get the path on the end and click on Save Example

15. Go back into your request. Replace postman-echo.com with the mock URL—keeping the /get path on the end

16. Click Send to see the edited response from the mock server

--

--