Creates a mock rule.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
mse:AddMockRule |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| Name |
string |
Yes |
The name of the rule. |
agent-auto-test-sc |
| Region |
string |
Yes |
The region ID. |
cn-hangzhou |
| Source |
string |
Yes |
The source of the rule. |
edasmsc |
| ProviderAppId |
string |
No |
The ID of the provider application. |
dcqtkuhnc4@66e5235415**** |
| ProviderAppName |
string |
No |
The name of the provider application. |
demo-cartservice |
| ExtraJson |
string |
Yes |
The description. |
{} |
| ScMockItems |
string |
Yes |
The input parameters. The value must be a JSON string. |
[] |
| DubboMockItems |
string |
Yes |
Specifies the project in the recycle bin. |
[] |
| ConsumerAppIds |
string |
Yes |
The ID of the custom application. |
[{\"appName\":\"provide\",\"appId\":\"bst8l6o735@f6d8aaf6e56e67d\"}] |
| Enable |
boolean |
No |
Specifies whether to enable the mock rule. Valid values:
|
true |
| MockType |
integer |
No |
Specifies the response time (RT) of a slow call. Valid values:
|
1 |
| AcceptLanguage |
string |
No |
The language of the response. Valid values:
|
zh |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The data structure. |
||
| HttpStatusCode |
integer |
The HTTP status code. |
200 |
| Message |
string |
The returned message. |
请求处理成功 |
| RequestId |
string |
The request ID. |
316F5F64-F73D-42DC-8632-01E308B6**** |
| Data |
object |
Data Overview. |
|
| NamespaceId |
string |
The namespace ID. |
cn-shanghai |
| ScMockItemJson |
string |
The mock rule for the HTTP protocol. |
[{"oper":"return+json","Path":"/mock","Value":"{\n \"date\": \"2021-09-10T07:45:12.357+0000\",\n \"name\": \"name\",\n \"id\": \"1\"\n}","Method":"GET","Condition":"AND","Timeout":1,"ArgumentMockItems":[{"type":"param","name":"id","value":"1","cond":"==","operator":"rawvalue"},{"type":"param","name":"name","value":"aliyun","cond":"==","operator":"rawvalue"}]}] |
| ConsumerAppName |
string |
The name of the application to query. |
demo-xxxx |
| ConsumerAppId |
string |
The ID of the consumer application. |
hkhon1po62@a000601b265xxxx |
| AccountId |
string |
The account ID. |
178432728867xxxx |
| ExtraJson |
string |
The description. |
desc |
| Source |
string |
The source. |
edasmsc |
| Region |
string |
The region. |
cn-shanghai |
| ProviderAppId |
string |
The ID of the provider application. |
hkhon1po62@a000601b265xxxx |
| ProviderAppName |
string |
The name of the provider application. |
demo-xxxx |
| Name |
string |
The name. |
mse-bc1a29b0-160230875****-reg-center-0-1 |
| Id |
integer |
The rule ID. |
275 |
| Enable |
boolean |
Indicates whether the rule is enabled.
|
true |
| MockType |
integer |
The model type. Valid values:
|
0 |
| Code |
integer |
The return code. |
200 |
| Success |
boolean |
Indicates whether the request was successful. Valid values:
|
true |
Examples
Success response
JSON format
{
"HttpStatusCode": 200,
"Message": "请求处理成功",
"RequestId": "316F5F64-F73D-42DC-8632-01E308B6****",
"Data": {
"NamespaceId": "cn-shanghai",
"ScMockItemJson": "[{\"oper\":\"return+json\",\"Path\":\"/mock\",\"Value\":\"{\\n \\\"date\\\": \\\"2021-09-10T07:45:12.357+0000\\\",\\n \\\"name\\\": \\\"name\\\",\\n \\\"id\\\": \\\"1\\\"\\n}\",\"Method\":\"GET\",\"Condition\":\"AND\",\"Timeout\":1,\"ArgumentMockItems\":[{\"type\":\"param\",\"name\":\"id\",\"value\":\"1\",\"cond\":\"==\",\"operator\":\"rawvalue\"},{\"type\":\"param\",\"name\":\"name\",\"value\":\"aliyun\",\"cond\":\"==\",\"operator\":\"rawvalue\"}]}]",
"ConsumerAppName": "demo-xxxx",
"ConsumerAppId": "hkhon1po62@a000601b265xxxx",
"AccountId": "178432728867xxxx",
"ExtraJson": "desc",
"Source": "edasmsc",
"Region": "cn-shanghai",
"ProviderAppId": "hkhon1po62@a000601b265xxxx",
"ProviderAppName": "demo-xxxx",
"Name": "mse-bc1a29b0-160230875****-reg-center-0-1",
"Id": 275,
"Enable": true,
"MockType": 0
},
"Code": 200,
"Success": true
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | IllegalRequest | Invalid request:%s | Invalid request: %s |
| 400 | InvalidParameter | Parameter error:%s | Request parameter error: %s |
| 500 | InternalError | Console error. Try again later:%s | Console error. Try again later: %s |
| 403 | NoPermission | You are not authorized to perform this operation:%s | You do not have the permission to use this interface:%s |
| 404 | NotFound | Not found:%s | The resource does not exist:%s |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.