How to Mock API Server in Postman

A mock API server or mock server API imitates a real API server by providing realistic mock API responses to requests. Responses can be static or dynamic as per your requirement, and they simulate the data the real API would return, matching the API schema. It is not always easy for an automation engineer to check the code based on multiple test data input as you cannot change the actual API data or it can be in the development phase but with the help of this, we can test or check the multiple test scenarios based on the mock test data.

Step 1: Open Postman and Click on “Create Mock Servers”

Step 2: Enter Request URL path, Response code and Response body as per your requirements.

Note: Don’t add URL only path. example add/create or add

Step 3: Enter Mock server name and click on “Create Mock Server”.

Step 4: Your mock server is set up now.

Postman will create an Environment for you and you can see in the atatched screenshot as well and in order to access the mock server URL you need to do 2 things:

a) Select your environment.

b) Insist of complete server URL, only enter {{url}}.

Step 5: Now if you click on “send”, you will get the mock response.

Step 6: Now click on three dots and click on “add example” to add more examples to mock your request.

Step 7: You can create as many examples. Here I have created a Post request for Ping URL and I have set up the status code and response body accordingly.

You can also create an incorrect request example. For example when a user tries to hit GET request instead of POST.

Geek Culture

Proud to geek out. Follow to join our +1.5M monthly readers.