edit-icon download-icon

Configure Mock

Last Updated: Oct 10, 2018

A project is typically developed by multiple partners working together toward a specific target. The interdependence among the various stakeholders often restricts individual members during the process, and misunderstandings may adversely influence the development process or even impact the project timing. 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 supports simple configuration in Mock mode.

Configure a Mock

Click API Edition > Basic Backend Definitions to configure the Mock.Configure Mock

1.Enter the Mock response result

You can enter the actual response result in the Mock response result field. Currently, the system supports Mock response results in JSON, XML, and text formats. For example:

  1. "result"
  2. :title":"Mock test for API Gateway

Save the Mock configuration and release it to the testing or production environment for debugging based on your needs. You can also debug on the API debugging page.

2. Enter response statusCode

The following table lists the valid values of statusCode. Format and status of HTTP 1.1 response status codes are supported. If you specify a statusCode that is not listed in the following table, the system reports an error indicating that the parameter is invalid.

http 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 Requried
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.Define a Mock header

API Gateway supports custom Mock headers and duplicate header names. The value of a header name cannot be empty and may only contain numbers, letters, underscores (_), and hyphens (-). The value of a header cannot be empty.

Remove a Mock

To remove a Mock, configure a different backend service. The value of the Mock response result is not removed and you can use the value for the next Mock setting. You need to release the change. A change takes effect only after being released.

Thank you! We've received your feedback.