-
Notifications
You must be signed in to change notification settings - Fork 24
API Mock Tutorial: Getting Started
Matthew Gallina edited this page Dec 12, 2019
·
15 revisions
This section provides step by step instructions of how to create a simple 'static' HTTP mock once you have sMockin successfully installed to your system.
Details on how to install sMockin can be found here Installation
-
Open http://localhost:8000/index.html in your browser
-
Under the HTTP tab click the New HTTP Endpoint button
-
From the New HTTP Endpoint page:
- Enter /helloworld under the Path field
- Select GET under the Method field
- Ensure HTTP Sequenced Based is selected as the mock type
-
Click the Add Seq Response button
-
In the New Sequenced Response window enter:
- application/json as the Content Type
- 200 as the HTTP Status Code
- { "msg" : "Hello World!" } in the Response Body
- Set Occurrence to 1
- Leave the Response Headers empty
- Click the Add button (which will close the window)
- Finally click Save button on the New HTTP Endpoint page
- The new mock /helloworld, should now be present under the HTTP tab in the dashboard
- Clicking on this will reveal the Deployment Status of the mock to either OFFLINE or PENDING if the mock server is already running
- To deploy the mock to the mock server, click the play button (or stop and then start if the server is already running)
- Open a terminal window and run the cURL command:
- curl -i -X GET http://localhost:8001/helloworld
- Alternatively simply open a browser and go to http://localhost:8001/helloworld which should display the "Hello World!" json response.