How to Setup Postman Mock Server

I wrote these tutorials for myself in future when I forget for the next steps.
Search for a command to run...

I wrote these tutorials for myself in future when I forget for the next steps.
No comments yet. Be the first to comment.
When you provision an Ubuntu instance on Oracle Cloud, you'll notice something different from standard Ubuntu installations: the system uses iptables instead of ufw for firewall management. This disti

When developing web applications locally, HTTPS is often overlooked. Yet, modern browsers and APIs increasingly require secure connections—even in development. That’s where mkcert comes in: a simple t

Testing the checkout success page in Magento 2 can be frustrating. By default, once an order is placed, Magento clears the quote session, meaning you can’t simply refresh or revisit the success page without going through the entire checkout process a...

Magento Commerce (EE) offers powerful features, but for many teams, Open Source (CE) is leaner, lighter, and more sustainable. If you're migrating from EE to CE, the Opengento downgrade tool provides a clean, scriptable way to remove proprietary modu...

If you’ve ever checked your Apache error logs and seen something like this: Code [core:error] (13)Permission denied: access to /robots.txt denied (filesystem path '/home/username/sites') because search permissions are missing on a component of the pa...

When you’re developing a project with a third party for the API service, you must need their development / sandbox site to develop and run test instead of running the test using their (3rd party) production site. But, sometimes their sandbox is not ready or in the worst case they have no sandbox site to run the test.
You can use postman to create the mock server to run test base on the case you’d like to develop. Postman provides this feature free (of course it has limitation, mate), for more information of postman mock server limitation you can read on this page https://www.postman.com/pricing/. Okay, be ready for the steps (I’m using Postman v8.10.0) :
Create new collection if you have no collection on your workspace. You may rename your new collection, in this case I rename my collection to "Mock Server".
You need to create new environment to handle the address. It’s not a mandatory actually, but it will make your development much easier, so just do this step on your own.
In this case i’m creating base_url, so what is it? once you created a new mock server, you will have endpoint URL. We need to store this URL so you don’t have to change the endpoint URL on every request.
You don’t have to have base_url as the variable, you may use whatever you like to use. Just leave empty for the initial value & current value, why? because we haven’t setup the mock server.
Simply just go to mock server menu.
Then configure the mock server to match with the environment we previously created.
as the result, you will have mock server URL as your endpoint URL address.
In Step 2.2 we created base_url environment variable, copy mock server URL as a value to this variable.
Then once collection is ready, prepare new / existing request to handle the request. in this case, I’m creating new request called "Authentication".
Then once you’ve finish creating new request, you need to setup the request. in this case, I’m creating such as a login feature by sending username & password.
This is the main point, you need to create response example for the request.
Then setup the response (body & header).
In this test case I hit the API by postman & terminal (just to make sure it works perfectly just like what I want).