All Products
Search
Document Center

API Mock

Last Updated: Apr 27, 2021

Mock the returned value of a certain API to provide specific response. To use API Mock function, go to the Manage gateway > Function switch page to turn API Mock on.

Procedure

The procedure of configuring API Mock is as follows:

  1. Under the Manage APIs tab, click More > API Mock right to a specific API in the API list.

    mock

  2. On Mock configuration page, configure the following parameters:

    • API Mock: Enable or disable the API Mock.
    • Hit rule: Currently, API Mock supports Percentage rule.
    • Rule configuration: Specific percentage value, the value range is 0 ~ 100.
    • Mock data: Mock API response data.
      The Mock data is in the following format:

      1. {
      2. "resultStatus": 1000,
      3. "tips": "ok",
      4. "result": "==Enter the Mock business data here =="
      5. }

      In the above codes:

      • resultStatus refers to the returned result code. For the concrete meaning, see Gateway result codes.
      • tips refers to the response tip.
      • result refers to the custom response data in JSON format.
  3. Click Submit to enable API Mock.