May 8, 2018

Running a Mock API server using mocktastic

A short how-to on running your mock API server using mocktastic.

Never heard of Mocktastic before? Well, Mocktastic is a cross platform, downloadable, GUI desktop application, which allows you to easily mock up any REST API without having to write a single line of code. Anybody can create a mock API server, and then share it with their team, so the entire team can use it. Click here to know more!
Running a Mock API server using mocktastic

This is a continuation of our how-to on mocking and running REST APIs using mocktastic. In this part, we will see how to run the server we mocked up in the last part.

Running the Server
  • To run a server, all you have to do is click the play button on the server page [1].

That's it. Your server is now running! You can now make a HTTP request to this server using curl like this:

$ curl http://localhost:5000/endpoint
    "success": true,
    "message": "Congratulations! You've made a successful request."

If you want to get the error response instead, just add the 'X-Mocktastic-Return-Status' header, with the value '400' like this:

$ curl http://localhost:5000/endpoint -H "X-Mocktastic-Return-Status: 400"
    "success": false,
    "message": "Looks like you did something wrong :("
Stopping the Server
  • Once your server is running, the button will now change to a stop button. Clicking on this, will stop your server [2].

That's it. You can now easily run your server and get it to respond with different response codes.