Mock

The Mock interceptor enables the user to create a default response to be displayed whenever the API is invoked.

Configuring the interceptor

When you insert the Mock interceptor into your API flow, the following pieces of information may be entered:

  • Headers: defining the response headers, with each header being separated by key and value. E.g.: quantity_requests = 20, with the delimiter being = or :. In case you need to insert more than one header in your Mock, you may do so by placing one value per line.

  • Body: defining the body of the response.

  • Status: defining the HTTP code of the response.

The image below displays the screen with all data filled out.

Mock interceptor configuration example

How it works

This interceptor may only be added in the request flow.

Imagine that you are testing a code and a given API has not been implemented on the back-end side yet. You may add the Mock interceptor to your API flow and it will simulate the backend response, returning whatever you configure it to do.

Interceptors are executed in the order they appear in the flow, and the flow is always executed until the end. The difference is that the request will not be forwarded to the destination.

The Mock interceptor will not interrupt the flow. All interceptors will run as expected, even if they are positioned after the Mock interceptor.

To set up a simulation that performs in a way that is closer to reality, place the Mock interceptor last, as shown in the image below. To change the order of the interceptors just drag and drop the interceptor to the desired position.

Example flow configured with Log
If there is a Log interceptor after the Mock interceptor, it is necessary to add the Content-Type header with the value text/* or application/json for a better view of the details. If the values cited are not informed, the data returned by the Mock interceptor will be encrypted and displayed in Base64.
Thanks for your feedback!
EDIT

Share your suggestions with us!
Click here and then [+ Submit idea]