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. In the right-hand pane, click /{productId} to view the endpoint details.
  2. Scroll to the bottom and click GET for the /products/{productId} endpoint.
  3. Scroll to the bottom of the response and click the blue Try it button. This takes you to the Parameters menu.
  4. To test the request, enter 2 into the productId* text field.
  5. Click Authorize and Send.
  6. Insert the following credentials in the modal that pops up.
    • username: mulesoft
    • password: mulesoft
  7. Click Send.

The mocking service 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.