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.

Note

Note

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 the /products/{productId} API endpoint.
  2. Click GET.
  3. Click the blue Try it button. This takes you to the Authorization, Parameters, and Headers menu. If you can't see the button, try resizing the Mocking service pane by clicking on the bar between it and the code pane. API Designer with a red arrow pointing at the Try it button, and a red arrow pointing at the bar between the code and the mocking service.
  4. Then, click on the Parameters tab.
  5. To test the request, enter 2 into the productId* text field.
  6. Then, click on the Authorization tab.
  7. Insert the following credentials in the modal that pops up.
    • username: mulesoft
    • password: mulesoft
  8. 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.