To Simulate Calling a RAML API (Mocking)

Requires November 2017 Release

Simulating calls to the API is a critical design task that helps you troubleshoot problems and demo the API to prospective users even before you have implemented it. You can simulate calls to the API in Design Center before publishing the API or in Exchange after publication there. To simulate calls to the API, you need to include a few things in the definition of a RAML resource at design time:

  • An example of data the actual implementation would return

  • An HTTP status code the API returns if successful

The mocking service can provide a base URI for an API you haven’t implemented yet. The mocking service reacts to http requests by returning responses based on your RAML design.

This example builds on the Placeholder API example and simulates a call to the API in Design Center. The steps to simulating calls to the API in Exchange after publication are similar. After a successful call to the API, the mocking service returns the status code 200 and example data you coded in the RAML.

  1. After entering RAML code in the editor, the API Summary displays resources.


  2. Turn on Mocking Service on the top right to simulate calls to the API.


    In your RAML definition, the baseUri changes to a mocking service URI.

  3. Expand resources to see methods. Click GET. Try It appears.

  4. Click Try It, and then click Send.

    The user information in the /users resource appears.

  5. Click the GET tab for the /userbyid resource. Click Try it.

  6. Check Show Optional Parameters, and enter a query parameter ID = 3. Click Send.

    The user information appears for the user having an ID 3.

  7. Turn off the mocking service before publishing to Exchange.

In this topic: