Simulating Calls to the API (Mocking) Reference

To simulate calls to the API, you need to prepare the RAML code as described in the linked topic To Simulate Calling an API (Mocking). The code needs to contain example responses. A response can consist of the following things:

  • HTTP status codes the API returns on success or failure

  • An example of data that the API returns on success

For example:


In body, you define an example. The example is typically a snippet of the data you’d expect to get from calling the method of this resource. Ideally, when you design the API, you include responses for other common HTTP status codes: 400, 401, 404, 405, 406, and 415.

Activating the Mocking Service

In API Summary, you can make an actual (not simulated) calls to the API under the following conditions:

  • You implemented the API and users can access the REST service.

  • You provided the working URI in the baseURI RAML property

Otherwise, you can simulate a call to the API using the mocking service. Before you activate the mocking service, the API uses the baseURI value you specified, if any, in the RAML design. In the example, the baseURI is

designer resources

After you activate the mocking service, the mocking service exposes a mock service that you can use for testing in lieu of an actual implementation. You activate the mocking service in Design Center:


The mocking service modifies the baseUri in the RAML. For Example:

#%RAML 1.0
title: placeholder
version: 1.0
# baseUri:

This RAML change puts the mocking service URI into effect. The URI is a proxy that prevents the simulation from getting blocked by a same-origin restriction policy. The mocking service reacts to HTTP requests by returning responses based on your RAML design.

Responses to Calls to the API

When you make a successful call to the API, the mocking service returns the status code 200 and example contained in your RAML code. If you omit the example snippet of data when designing the RAML, the following actions occur:

  • The mocking service trys to resolve the request.

  • The mocking service returns a status 200 and a message that says the RAML had no response information.

You can use any one of the following tools to simulate calling the API using the mocking service:

  • Design Center

    Use the controls in API Summary, following the steps in the topic To Simulate Calling an API.

  • Exchange after publishing the API

    Use the controls in API Summary to simulate calling the API.

  • An HTTP client, such as Postman

  • The curl command

If your API design supports query parameters, you can use query parameters in the simulated call. If the parameter you enter when calling the API doesn’t match the specifications of your design, the mocking service returns an error to indicate an invalid parameter.

Turn off the mocking service before publishing an API to Exchange. You can re-activate the mocking service from Exchange after publication.