Skip to content

API Mock Tutorial: Applying Sequences

Matthew Gallina edited this page Dec 12, 2019 · 16 revisions

To help imitate real world behaviour, HTTP mocks can be configured to return different responses per call, using either Sequences, Rules or via an External Feed.

In this section we will explore how to use Sequences and apply this to the /helloworld mock created under the Getting Started step.


Updating the Mock

  • Open http://localhost:8000/index.html in your browser

  • Under the HTTP tab, locate the mock /helloworld and click the View button

  • From the HTTP Endpoint page, click on 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" : "Bonjour le Monde!" } in the Response Body
    • Set Occurrence to 2
    • Again, leave the Response Headers empty
  • Click the Add button and then lastly the Save button.

  • Finally from the dashboard restart the mock server


Calling the Mock

The /helloworld mock should now return 2 different responses.

The 1st call should return "Hello World!", whilst the 2nd and 3rd calls should then return "Bonjour le Monde!" (as we set the Occurrence to 2).

A 4th call will go back to the beginning of the list and therefore return "Hello World!".

Give it a try:


Next Step:

Applying Rules