错误返回
更新时间:2026-09-29
当用户访问 API 出现错误时,会返回相应的错误码和错误信息,便于定位问题,并做出适当的处理。请求发生错误时通过 Response Body 返回详细错误信息,遵循如下格式:
| 参数名 | 类型 | 说明 |
|---|---|---|
| code | String | 表示具体错误类型 |
| message | String | 有关该错误的详细说明 |
| requestId | String | 本次请求的 requestId |
示例:
Plain Text
1{
2 "requestId" : "ae2225f7-1c2e-427a-a1ad-5413b762957d",
3 "code" : "InstanceNotExist",
4 "message" : "Instance not exist."
5}
公共错误码
下表列出了百度智能云 API 的公共错误码。
| 错误码 | 错误消息 | HTTP 状态码 | 描述 |
|---|---|---|---|
| AccessDenied | Access denied. | 403 Forbidden | 无权限访问对应的资源 |
| 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 does not exist in our records. | 403 Forbidden | Access Key ID 不存在 |
| InvalidHTTPAuthHeader | The Access Key ID you provided does not exist in our records. | 400 Bad Request | 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 不匹配的问题,应定义更加具体的错误码,如 InstanceNotExist |
| MalformedJSON | The JSON you provided was not well-formed. | 400 Bad Request | JSON 格式不合法 |
| OptInRequired | A subscription for the service is required. | 403 Forbidden | 没有开通对应的服务 |
| RequestExpired | Request has expired. Timestamp date is <Date>. | 400 Bad Request | 请求已过期,签名时间戳超出有效期 |
| SignatureDoesNotMatch | The request signature we calculated does not match the signature you provided. Check your Secret Access Key and signing method. Consult the service documentation for details. | 400 Bad Request | Authorization 头域中附带的签名和服务端验证不一致 |
API 网关专享版错误码
下表汇总了 API 网关专享版 API 的错误码。各接口实际可能返回的错误码,以对应接口文档的错误码章节为准。
| 错误码 | 错误消息 | HTTP 状态码 | 描述 |
|---|---|---|---|
| ConsumerAuthNotEnabled | Consumer authentication is not enabled on target service or api. | 400 Bad Request | 目标服务或 API 未开启消费者认证 |
| HttpMessageNotReadable | Http Message Not Readable: JSON parse error | 400 Bad Request | 请求体不是合法 JSON,无法解析,请检查 JSON 语法和字段类型 |
| InstanceEipNotAvailable | EIP is not available or not belongs to the account. | 400 Bad Request | EIP 不可用或不属于当前账号 |
| InvalidOpenBls | Invalid blsConfig for OpenBls API. | 400 Bad Request | 开启 BLS 日志监控时传入的 blsConfig 不合法 |
| InvalidOpenOtel | Invalid otelConfig for OpenOtel API. | 400 Bad Request | 开启 OTel 链路追踪时传入的 otelConfig 不合法 |
| MethodArgumentNotValidException | MethodArgumentNotValidException: {字段名} {校验消息} | 400 Bad Request | 必填参数缺失或格式不合法,具体字段与原因见错误消息 |
| NotEnabledBls | The instance has not enabled BLS. | 400 Bad Request | 实例尚未开启 BLS 日志监控 |
| NotEnabledMetric | The instance has not enabled metric. | 400 Bad Request | 实例尚未开启指标监控 |
| NotEnabledOtel | The instance has not enabled OTel. | 400 Bad Request | 实例尚未开启 OTel 链路追踪 |
| RepeatedlyOpenBls | The instance has been bound to BLS. | 400 Bad Request | 实例已开启 BLS 日志监控,无需重复开启 |
| RepeatedlyOpenMetric | The instance has been bound to metric. | 400 Bad Request | 实例已开启指标监控,无需重复开启 |
| RepeatedlyOpenOtel | The instance has been bound to OTel. | 400 Bad Request | 实例已开启 OTel 链路追踪,无需重复开启 |
| ResourcePermissionDeny | Resource permission deny. | 401 Unauthorized | 无权限访问指定资源,请确认资源属于当前账号 |
| ApiNotExist | Api not exist. | 404 Not Found | API 不存在、不属于当前账号或已删除 |
| AuthorizationInfoNotExist | Authorization info AK_SK not exist. | 404 Not Found | 消费者的 AK/SK 凭证不存在或已删除 |
| AuthorizationNotExist | Authorization not exist. | 404 Not Found | 消费者授权规则不存在或已删除 |
| BackendNotExist | Backend not exist. | 404 Not Found | 后端不存在、不属于当前账号或已删除 |
| ConsumerNotExist | Consumer not exist. | 404 Not Found | 消费者不存在、不属于当前账号或已删除 |
| Instance.HpasFlavorNotExist | instance flavor not exist. | 404 Not Found | 指定的实例规格不存在 |
| InstanceNotExist | Instance not exist. | 404 Not Found | 网关实例不存在、不属于当前账号或已释放 |
| ParamCheckError | Invalid AiModel URL. | 404 Not Found | 请求参数或关联资源校验不通过,具体项见错误消息,如服务地址非法、模型供应商无效、证书不存在、配额重置周期参数越界 |
| PluginReleaseBindNotExist | Plugin release bind not exist. | 404 Not Found | 插件绑定不存在或已卸载 |
| PluginReleaseNotExist | Plugin release not exist. | 404 Not Found | 插件不存在或已删除 |
| ResourceNotExist | Domain not exist. | 404 Not Found | 引用的资源不存在,如后端类型、域名、模型服务映射 |
| ServiceNotExist | Service not exist. | 404 Not Found | 服务不存在、不属于当前账号或已删除 |
| InstanceDeleteDenied | There are still services surviving under the instance. | 409 Conflict | 实例下仍有服务,需先删除全部服务再释放实例 |
| ApiKeyRepeat | API Key already exists in this account. | 413 Request Entity Too Large | 该 API Key 在当前账号内已存在 |
| AuthorizationRuleIsExist | Authorization rule is exist. | 413 Request Entity Too Large | 消费者授权规则已存在 |
| QuotaCheckError | Backend count exceed quota {quota}. | 413 Request Entity Too Large | 资源数量超出配额上限,如后端、服务、消费者、API Key、授权数量,可删除闲置资源或申请提额 |
| ResourceHaveBind | Backends having apis bind. | 413 Request Entity Too Large | 资源已被引用或已绑定,如后端被 API 引用、域名已绑定服务、消费者已绑定服务或 API,需先解除绑定 |
| ServiceNameRepeat | Service name Repeat. | 413 Request Entity Too Large | 服务名称在当前账号内已存在 |
| HttpMediaTypeException | HttpMediaTypeException: Content-Type 'text/plain' is not supported | 415 Unsupported Media Type | 请求的 Content-Type 不受支持,请使用 application/json |
| CreateInternalException | An error occurred during instance creation | 500 Internal Server Error | 网关内部错误,如创建实例或绑定域名等操作下发数据面时 K8s 调用失败,请稍后重试或联系技术支持 |
| DataPlaneSyncFailed | 配置已保存成功,但网关操作失败,请稍后重试或联系技术支持。 | 500 Internal Server Error | 配置已写入控制面,但下发数据面失败,请稍后重试或联系技术支持 |
| InstanceEipBindFailed | Bind EIP to instance failed. | 503 Service Unavailable | 绑定 EIP 到实例失败,请稍后重试 |
评价此篇文章
