Creates a block fallback definition in Microservices Engine (MSE). A block fallback definition specifies the response that a client receives when Sentinel flow control or circuit breaking rules block a request, such as an HTTP 429 status code with a custom JSON body.
Try it now
Try this API in OpenAPI Explorer. OpenAPI Explorer signs requests automatically and generates SDK samples that you can download and run locally.
RAM authorization
Grant the following permission in a Resource Access Management (RAM) policy before you call this API operation.
| Action | Access level | Resource type | Condition key | Dependent action |
|---|---|---|---|---|
| mse:CreateSentinelBlockFallbackDefinition | update | All resources * | None | None |
For details on policy elements, see Common condition keys.
Request parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| AppName | string | No | The application name. | example-app |
| Namespace | string | No | The MSE namespace. | test |
| RegionId | string | No | The region ID. | cn-hangzhou |
| Language | string | No | The programming language, such as Java or Go. | JAVA |
| ResourceClassification | integer | No | The resource type that the fallback applies to. Valid values: 1 (Web), 2 (RPC). | 1 |
| FallbackBehavior | string | No | The behavior details, specified as a JSON string. | {"webFallbackMode":0,"webRespMessage":"{}","webRespStatusCode":429,"webRespContentType":0} |
| Name | string | No | The name of the fallback definition. | MyFallback |
| Scenario | string | No | The scenario. Set this to default. | default |
| AppId | string | No | The application ID. Optional. | abcde@12345 |
| Source | string | No | Redundant parameter, currently ignored. | edasmsc |
| AcceptLanguage | string | No | The language for response messages. Valid values: zh (default, Chinese), en (English). | zh |
Response parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| Code | integer | The response code. 200 indicates success. | 200 |
| Success | string | Whether the request succeeded. Valid values: true, false. | true |
| Message | string | The response message. | success |
| RequestId | string | The request ID. | ADDD8AB7-8D1C-4697-A83E-410D2607\*\*\*\* |
| HttpStatusCode | integer | The HTTP status code. | 200 |
| Data | object | The created fallback definition. See the following table. |
Data object
| Parameter | Type | Description | Example |
|---|---|---|---|
| Id | integer | The ID of the created fallback definition. | 34726 |
| AppName | string | The application name. | spring-cloud-a |
| Namespace | string | The namespace. | default |
| Name | string | The fallback definition name. | test |
| ResourceClassification | integer | The resource type. 1: Web, 2: RPC. | 1 |
| FallbackBehavior | string | The fallback behavior as a JSON string. | {"webRespStatusCode":429,"webRespMessage":"test","webFallbackMode":0,"webRespContentType":0} |
| UserId | string | The user ID. | 123456 |
Examples
Sample response
{
"Message": "success",
"RequestId": "ADDD8AB7-8D1C-4697-A83E-410D2607****",
"Data": {
"ResourceClassification": 1,
"UserId": "123456",
"AppName": "spring-cloud-a",
"Id": 34726,
"Namespace": "default",
"Name": "test",
"FallbackBehavior": "{\"webRespStatusCode\":429,\"webRespMessage\":\"test\",\"webFallbackMode\":0,\"webRespContentType\":0}"
},
"Code": 200,
"Success": "true",
"HttpStatusCode": 200
}Error codes
| HTTP status code | Error code | Error message | Description |
|---|---|---|---|
| 400 | IllegalRequest | Invalid request:%s | The request format is invalid. Verify the request body and parameter values. |
| 400 | InvalidParameter | Parameter error:%s | A parameter is missing or invalid. Check parameter names, types, and allowed values. |
| 403 | NoPermission | You are not authorized to perform this operation:%s | The caller lacks the required RAM permission. Attach a policy that grants the mse:CreateSentinelBlockFallbackDefinition action. |
| 404 | NotFound | Not found:%s | The specified resource does not exist. Verify the application name, namespace, and region ID. |
| 500 | InternalError | Console error. Try again later:%s | An internal error occurred. Retry the request after a brief wait. If the error persists, contact technical support. |
For a complete list, see Error codes.
Release notes
For the change history of this API, see Release notes.