Mock servers

A mock server is a fake API that simulates a server response but behaves like a real API. It has an internal logic that allows to determine which response should be returned for a particular request.

  1. Click on the new button next to your workspace. Then select Mock server.


  2. Enter the requests that you want to mock as shown below. Then click Next


  3. Enter the mock server name and click Create Mock Server.


  4. You should now be able to see your mock server collection created with two GET requests and the url of your mock server.


  5. Click on the first GET request. This request is composed of a {{url}} variable followed by the request path you specified.


  6. If you put the cursor over the {{url}} variable, you will notice that this variable is not defined in this environment. Change the enviroment to First Mock Server by clicking on the No environment tab on the top right corner.


  7. Your {{url}} variable is now defined within this environment and has a value the url automatically generated when you created this mock server.
  8. Click on Send and check the response Body returned by your mock server.


  9. The request above returns a simple text in html. You can create another variant that returns the response in json format. To do so, click on the three dots next to GET users/1 and select Add example. Name it jsonResponse. Change the url as shown below. In the Body change the format from text to json and enter the response as shown below.


  10. To try the jsonResponse example, click again on the GET request, add /json to the url and click Send. You should see the response returned in json.*
  11. Done!
teaching_assistant/api/postman_test_mock.txt · Last modified: 2021/09/21 23:26 by Nour
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0