Start tracking your progress
Trailhead Home
Trailhead Home

Test the API Spec

Test the API with Mocking Service

It’s now time for you to test the API specification to prototype the implementation. First, turn on the built-in mocking service in API Designer by flipping the switch at top of the right-hand pane.

Arrow pointing to the Mocking service switch and the accompanying word “Flip.”

Once the Mocking service switch is flipped, you see a new parameter called baseUri show up at the top of your code—this public URL is the base path to accessing the API. All endpoints are appended to this base path.



The mocking service is only meant for testing and not for production use.

The mocking service allows you to simulate the behavior of an API during the design phase without implementing it. With the mocking service, you can speed up your project by implementing the API and the application consuming the API in parallel (instead of having the application dev team wait for the API implementation).

Send a Request to Mocking Service

The right-hand pane also includes the API console you can use to try a request and see the response.

  1. Click the blue Try it button. This takes you to the Authorization, Parameters, and Headers pane. If you can't see the button, try resizing the Mocking service pane by clicking the bar between it and the code pane.
  2. To test the request, enter 2 into the productId* text field.
  3. Insert the following credentials under the Basic Authentication heading
    1. username: mulesoft
    2. password: mulesoft
  4. Click Send.

Now, scroll down in the Mocking service pane. It should return a 200 response with the example body. This can be tested by performing a similar request using another web client such as curl or a web browser.

curl -X GET https://{{yourMockingServiceUrl}}/products/1

The mocking service URL can be shared with other stakeholders and should be tested during the design phase.

We won’t check any of your setup. Click Verify Step to go to the next step in the project.