A project is typically developed by multiple partners who work together toward a specific goal. The interdependence among various stakeholders often restricts individual members during the process, and misunderstandings may affect the development process or even delay the project schedule. Mock can be used early in the project development cycle to simulate activities and project results. This can greatly reduce miscommunication and misunderstanding among team members in the project development and greatly improve the development efficiency. API Gateway allows you to use Mock as the backend service of an API operation, which requires simple configurations.
Configure Mock

1. Specify a Mock response
Enter a response in the Mock Result field. The response will be returned for all requests for the current API operation. You can specify a Mock response in various formats, including JSON, XML, and text. The following code snippet is a sample of a Mock response:
{
"result": {
"title": " Mock test for API Gateway",
...
}
}
After you create an API operation that uses Mock as the backend service, you can publish the API operation to the test or production environment. You can also go to the debugging page to debug the API operation.
2. Specify the HTTP status code
The following table lists the valid HTTP status codes. HTTP/1.1 status codes are supported. If you enter a code that is not in the following table, a message appears in red next to the HTTP Status Code field, indicating that the code you entered is invalid.
HTTP status code | HTTP message |
---|---|
200 | OK |
201 | Created |
202 | Accepted |
203 | Non-Authoritative Information |
204 | No Content |
205 | Reset Content |
206 | Partial Content |
300 | Multiple Choices |
301 | Moved Permanently |
302 | Found |
303 | See Other |
304 | Not Modified |
305 | Use Proxy |
306 | (Unused) |
307 | Temporary Redirect |
400 | Bad Request |
401 | Unauthorized |
402 | Payment Required |
403 | Forbidden |
404 | Not Found |
405 | Method Not Allowed |
406 | Not Acceptable |
407 | Proxy Authentication Required |
408 | Request Timeout |
409 | Conflict |
410 | Gone |
411 | Length Required |
412 | Precondition Failed |
413 | Request Entity Too Large |
414 | Request-URI Too Long |
415 | Unsupported Media Type |
416 | Requested Range Not Satisfiable |
417 | Expectation Failed |
450 | Parameter Required |
451 | Method Connect Exception |
500 | Internal Server Error |
501 | Not Implemented |
502 | Bad Gateway |
503 | Service Unavailable |
504 | Gateway Timeout |
505 | HTTP Version Not Supported |
3. Specify Mock header fields
API Gateway supports custom Mock header fields and duplicate header field names. A header field name cannot be empty and can contain digits, letters, underscores (_), and hyphens (-). The value of a header field cannot be empty.
Remove Mock
To remove Mock as the backend service of an API operation, you only need to configure a different backend service for the API operation. The configurations of Mock will be retained, so that you can still switch to Mock if needed. After you change the backend service of the API operation, the change takes effect only after you publish the API operation.