错误返回
更新时间:2024-07-02
当用户访问API出现错误时,会返回相应的错误码和错误信息,便于定位问题,并做出适当的处理。请求发生错误时通过Response Body返回详细错误信息,遵循如下格式:
| 参数名 | 类型 | 说明 |
|---|---|---|
| code | String | 表示具体错误类型 |
| message | String | 有关该错误的详细说明 |
| requestId | String | 本次请求的requestId |
示例:
Plain Text
1 {
2 "requestId" : "ae2225f7-1c2e-427a-a1ad-5413b762957d",
3 "code" : "NoSuchKey",
4 "message" : "The resource you requested does not exist"
5 }
公共错误码
下表列出了百度智能云API的公共错误码。
| 错误码 | 错误消息 | HTTP状态码 | 描述 |
|---|---|---|---|
| AccessDenied | Access denied. | 403Forbidden | 无权限访问对应的资源。 |
| InappropriateJSON | The JSON you provided was well-formed and valid, but not appropriate for this operation. | 400 Bad Request | 请求中的JSON格式正确,但语义上不符合要求。如缺少某个必需项,或值类型不匹配等。出于兼容性考虑,对于所有无法识别的项应直接忽略,不应该返回这个错误。 |
| InternalError | We encountered an internal error Please try again. | 500 Internal Server Error | 所有未定义的其他错误。在有明确对应的其他类型的错误时(包括通用的和服务自定义的)不应该使用。 |
| InvalidAccessKeyId | The Access Key ID you provided doesnot exist in our records. | 403Forbidden | Access Key ID不存在。 |
| InvalidHTTPAuthHeader | The Access Key ID you provided does notexist in our records. | 400 BadRequest | Authorization头域格式错误。 |
| InvalidHTTPRequest | There was an error in the body of your HTTP request. | 400 Bad Request | HTTP body格式错误。例如不符合指定的Encoding等。 |
| InvalidURI | Could not parse the specified URI. | 400 Bad Request | URI形式不正确。例如一些服务定义的关键词不匹配等。对于ID不匹配的问题,应定义更加具体的错误码,如NoSuchKey。 |
| MalformedJSON | The JSON you provided was not well-formed. | 400 BadRequest | JSON格式不合法。 |
| InvalidVersion | The API version specified was invalid. | 404 NotFound | URI的版本号不合法。 |
| OptInRequired | A subscription for the service is required. | 403Forbidden | 没有开通对应的服务。 |
| PreconditionFailed | The specified If-Match header doesn’tmatch the ETag header. | 412PreconditionFailed | 详见Etag。 |
| RequestExpired | Request has expired. Timestamp date is <Data>. | 400 BadRequest | 请求超时。要改成x-bce-date。若请求中只有Date,需将Date转成datetime。 |
| IdempotentParameterMismatch | The request uses the same client token asa previous, but non-identical request. | 403Forbidden | clientToken对应的API参数不一样。 |
| SignatureDoesNotMatch | The request signature we calculated does not match the signature you provided. Check yourSecret Access Key and signing method. Consultthe service documentation for details. | 400 Bad Request | Authorization头域中附带的签名和服务端验证不一致。 |
BCC错误返回码
下表列出了BCC API特有错误码。
| 错误码 | 错误消息 | HTTP状态码 | 描述 |
|---|---|---|---|
| QualifyNotPass | The User has not pass qualify. | 403 | 账号没有通过实名认证 |
| BadRequest | Bad request parameters or illegal request. | 400 | 请求有误 |
| AuthError | No authentication or authentication error. | 401 | 权限错误 |
| AccessDenied | No permission to accessor or permission error. | 403 | 禁止操作 |
| NoSuchObject | The specified object is not found or resource do not exist. | 404 | 对象未找到 |
| IllegalOperation | Illegal operation type. | 405 | 操作类型错误 |
| OperationDenied | Operation not available. | 409 | 不可操作(重复名字、重建正在进行中等) |
| LimitExceeded | Limit exceeded for current request. | 413 | 超出限制 |
| ServiceInternalError | Internal service occurs error. | 500 | 服务内部错误 |
| ServiceUnavailable | Service is unavailable. | 503 | 服务不可用 |
| Volume.DiskIdIsEmpty | Volume id must be provided. | 400 | 磁盘id不允许为空 |
| Volume.DiskNameInvalid | Volume name is invalid. | 400 | 名称格式不正确 |
| Volume.DiskDescriptionInvalid | Volume description is invalid. | 400 | 描述格式不正确 |
| Volume.DiskSizeInvalid | Volume size is invalid. | 400 | 大小不合法 |
| Volume.VolumeTypeInvalid | Volume type is invalid. | 400 | 磁盘类型不正确 |
| Volume.DiskQuotaExceededLimit | Number of volumes exceeds limit. | 413 | cds磁盘超额 |
| Volume.DiskSizeQuotaExceededLimit | Volume size exceeds total capacity quota. | 413 | cds磁盘大小超额 |
| Instance.ReleaseTimeInvalid | Fail to update the instance scheduled release time settings. | 400 | 定时释放参数不正确 |
| Instance.AttachedVolumeExceededSnapshotLimit | Scheduled snapshot quota of your new mount CDS disk is exceeded, please change the policy or manually deleted non-scheduled snapshot. | 413 | 挂载cds磁盘数目超出限制 |
| Instance.SnapshotPolicyRetainsDaysInvalid | Days format of retention of scheduled snapshot is invalid. | 400 | 自动快照保留天数不合法 |
| Instance.SnapshotPolicyNameInvalid | The policy name of scheduled snapshot is invalid. | 400 | 自动快照策略名称不合法 |
| Instance.AdminPassDecryptionException | Invalid encryption code found for the admin password. | 400 | 无效的加密密码 |
| PaymentFailed | payment failed, please check remaining balance. | 403 | 支付失败 |
| Asp.NameInvalid | asp name is invalid. | 400 | 名称非法 |
| Asp.RetentionDaysInvalid | RetentionDays should in [1,10000] | 400 | 保留天数非法 |
| Asp.TimePointsInvalid | TimePoints should in [0,23] | 400 | 执行时间点参数异常 |
| Asp.RepeatWeekdaysInvalid | RepeatWeekdays should in [1,7] | 400 | 执行日期参数异常 |
| Asp.VolumeTypeInvalid | Volume type should be Cds or System | 400 | volume类型非法 |
| Asp.VolumeStatusInvalid | Volume must be in-use | 400 | volume状态必须为in-use |
| BadRequest | missing parameter. | 400 | 缺少参数 |
| ServiceInternalError | Internal service occurs error. | 500 | 内部错误 |
| BadRequest | Bad request parameters or illegal request. | 400 | 请求参数错误 |
| NoSuchObject | The specified object is not found or resource do not exist. | 404 | 指定的asp不存在 |
| BadRequest | Bad request parameters or illegal request. | 400 | 请求参数无效 |
