You need to enable JavaScript to run this app.
导航

如何调用API

最近更新时间2022.10.09 10:27:47

首次发布时间2022.10.09 10:27:47

本文为您介绍如何调用火山引擎 E-MapReduce(EMR)OpenAPI。

1 请求结构

火山引擎 EMR OpenAPI 的请求结构包含如下信息:

1.1 请求域名:

火山引擎 EMR OpenAPI 的域名为 open.volcengineapi.com。

1.2 通信协议

火山引擎 EMR OpenAPI 支持通过 HTTP 或 HTTPS 两种方式进行请求通信,推荐使用安全性更高的 HTTPS 方式发送请求。

1.3 请求方法

火山引擎 EMR OpenAPI 支持 GET 和 POST 请求方式。

1.4 请求参数

火山引擎 EMR OpenAPI 请求参数包含两类参数:

  • 公共请求参数:需在每个请求中都必须包含,详见:公共参数

  • 接口请求参数:接口请求参数需参考各个服务的接口文档,详见:API 说明文档

1.5 字符编码

请求及返回结果使用 UTF-8 的字符集进行编码。

2 公共参数

所有接口请求中都必须携带公共参数,为了避免重复说明,本文中不再重复描述这部分参数,请您在请求 API 时携带这部分参数,否则请求将无法通过合法性验证。

公共参数说明详见:公共参数

3 签名方法

火山引擎 OpenAPI 为保证请求者身份的合法性以及请求在传输过程中不被恶意篡改,火山引擎签名机制要求请求者对请求参数进行哈希值计算,经过加密后同API请求一起发送到服务器中,服务器将以同样的机制对收到的请求进行签名计算,并以此与请求者传来的签名进行比对,若签名未通过验证,请求将被拒绝。

具体计算签名方法,请详见:签名方法

4 返回结果

以请求 CreateCluster(创建集群)接口为例,返回成功结果示例如下:

{
    "ResponseMetadata": {
        "RequestId": "20211230204359010225243125031xxx", 
        "Action": "CreateCluster", 
        "Version": "2022-06-30", 
        "Service": "emr", 
        "Region": "cn-guilin-boe", 
        "Error": null
    }, 
    "Result": {
        "OrderId": "Orderxxxxx",
        "ClusterId": "emr-12345"
    }
}
名称描述
ResponseMetadata:通用返回信息,结构如下
RequestId唯一标识 TOP 请求的 ID。
ActionTOP 上注册的 Action 名称。
VersionAPI 的版本号。
ServiceAPI 的服务名。
Region火山引擎的地域。
Error错误信息,如果为空代表调用成功。
Result:结果
OrderId已支付的订单号,按量付费时返回。
ClusterIdEMR 集群的集群 ID

5 公共错误码

更多公共错误码详见:https://www.volcengine.com/docs/6369/68677

CodeCodeNMessage备注Status
MissingParameter100002The request is missing %s parameter.关键参数缺失,例如 Action, Version 参数。400
MissingAuthenticationToken100003Request is missing Authentication Token.缺少身份认证的必要信息,例如 Auth 信息。401
MissingRequestInfo100004The request is missing %s information.缺少请求必要信息,例如:Access Key,Service,Region 等。400
MissingSignature100005The request is missing signature.缺少签名结果。401

InvalidTimestamp

100006

The Signature of the request is expired.

请求过期或请求的签名时间来自未来。

400

ServiceNotFound100007This service[%s] not found.请求的服务不存在。404
InvalidActionOrVersion100008Could not find operation %s for version %s.请求接口不存在。404
InvalidAccessKey100009The accesskey [%s] included in the request is invalid.请求的 Access Key 不合法。401
SignatureDoesNotMatch100010The 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.签名结果不正确。401
LackPolicy100012Request was rejected because of lack of policy.子用户缺少权限。403
AccessDenied100013User is not authorized to perform: %s on resource: %s.子用户拥有的权限不支持当前操作。403
InternalError100014Service has some internal Error. Pls Contact With Admin.内部错误。500
FailToConnect100015Top Fail to Connect to Internal Service.已通过身份认证,但服务无法连接。502
InternalServiceTimeout100016Internal Service is timeout. Pls Contact With Admin.服务执行超时。504
FlowLimitExceeded100018Request was rejected because the request speed of this openAPI is beyond the current flow control limit.请求过于频繁,超出了基本限速。429
ServiceUnavailableTemp100019Service is busy, please try again later.处于熔断状态的服务暂时不可访问,稍后重试。503
MethodNotAllowed100020HTTP Method Not Allowed.Http method 不合法。405
InternalServiceError100023Service has some internal Error. Pls Contact With Admin.服务存在故障。502
InvalidAuthorization100024Invalid 'Authorization' header, Pls check authorization header.Authorization 头格式错误,检查 Authorization。400
InvalidCredential100025Invalid credential in 'Authorization', Pls check credential in authorization header.Authorization 头中的 Credential 格式错误,检查 Credential。400
InvalidSecretToken100026Invalid secret token, msg: %s.错误的 STS or STS2,可能是多种错误,例如签名错误、过期等。401