更新时间:2019-09-25 15:09
新建一个API。
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
Action | String | 是 | 操作接口名,系统规定参数,取值:CreateApi |
GroupId | String | 是 | 指定的分组编号 |
ApiName | String | 是 | 设置API的名称,组内不允许重复。支持汉字,英文,数字,下划线,且只能以英文和汉字开头,4~50个字符 |
Visibility | String | 是 | API是否公开,可以取值:
|
Description | String | 否 | API描述信息,最多180个字符 |
AuthType | String | 是 | API安全认证类型,目前可以取值:
|
AllowSignatureMethod | String | 否 | 当AuthType为APP认证时,需要传该值明确签名算法。可选值如下,不传默认是HmacSHA256:
|
AppCodeAuthType | String | 否 | 当AuthType为APP认证时,可选值如下,不传默认是DEFAULT:
|
ForceNonceCheck | Boolean | 否 | 设置ForceNonceCheck为true, 请求时强制检查X-Ca-Nonce,这个是请求的唯一标识,一般使用UUID来标识。API网关收到这个参数后会校验这个参数的有效性,同样的值,15分内只能被使用一次。可以有效防止API的重放攻击。设置ForceNonceCheck为false, 则不检查。创建API时默认为false。 |
DisableInternet | Boolean | 否 | 设置DisableInternet为true, 仅支持内网调用API。设置DisableInternet为false, 则不限制调用。创建API时默认为false。 |
WebSocketApiType | String | 否 | 双向通信API类型:
|
OpenIdConnectConfig | String | 否 | 第三方账号认证OpenID Connect相关配置项。 |
RequestConfig | String | 是 | Consumer向网关发送API请求的相关配置项。 |
ServiceConfig | String | 是 | 网关向后端服务发送API请求的相关配置项。 |
RequestParameters | String | 是 | Consumer向网关发送API请求的参数描述。 |
ServiceParameters | String | 是 | 网关向后端服务发送API请求的参数描述。 |
ServiceParametersMap | String | 是 | Consumer向网关发送请求的参数和网关向后端服务发送的请求的参数的映射关系。 |
ResultType | String | 否 | 后端服务返回应答的格式,目前可以设置为:JSON、TEXT、BINARY、XML、HTML。默认 JSON |
ResultSample | String | 否 | 后端服务返回应答的示例 |
FailResultSample | String | 否 | 后端服务失败返回应答的示例 |
ErrorCodeSamples | String | 否 | 后端服务返回的错误码示例。 |
名称 | 类型 | 描述 |
---|---|---|
RequestId | String | 本次创建API的请求Id |
ApiId | String | 本次创建API的Id |
https://apigateway.cn-qingdao.aliyuncs.com/?Action=CreateApi
&GroupId=08ae4aa0f95e4321849ee57f4e0b3077
&ApiName=ApiName
&Visibility=PUBLIC
&Description=Api description
&AuthType=APP
&RequestConfig={"RequestProtocol":"HTTP","RequestHttpMethod":"GET","RequestPath":"/v3/getUserTest/[userId]","BodyFormat":"FORM","PostBodyDescription":""}
&ServiceConfig={"ServiceProtocol":"HTTP","ServiceHttpMethod":"GET","ServiceAddress":"http://www.customerdomain.com","ServiceTimeout":"1000","ServicePath":"/v3/getUserTest/[userId]"}
&RequestParameters=[{"ParameterType":"Number","Required":"OPTIONAL","isHide":false,"ApiParameterName":"age","DefaultValue":"20","DemoValue":"20","Description":"年龄","MinValue":18,"MaxValue":100,"Location":"Head"},{"ParameterType":"String","Required":"OPTIONAL","isHide":false,"ApiParameterName":"sex","DefaultValue":"boy","DemoValue":"boy","Description":"性别","EnumValue":"boy,girl","Location":"Query"},{"ParameterType":"Number","Required":"REQUIRED","isHide":false,"ApiParameterName":"userId","MaxLength":10,"MinValue":10000000,"MaxValue":100000000,"Location":"Path"},{"ApiParameterName":"CaClientIp","ParameterLocation":{"name":"Head","orderNumber":0},"Location":"Head","ParameterType":"String","Required":"REQUIRED","Description":"客户端IP"},{"ApiParameterName":"constance","ParameterLocation":{"name":"Head","orderNumber":0},"Location":"Head","ParameterType":"String","Required":"REQUIRED","DefaultValue":"constance","Description":"constance"}]
&ServiceParameters=[{"ServiceParameterName":"age","Location":"Head","Type":"Number","ParameterCatalog":"REQUEST"},{"ServiceParameterName":"sex","Location":"Query","Type":"String","ParameterCatalog":"REQUEST"},{"ServiceParameterName":"userId","Location":"Path","Type":"Number","ParameterCatalog":"REQUEST"},{"ServiceParameterName":"clientIp","Location":"Head","Type":"String","ParameterCatalog":"SYSTEM"},{"ServiceParameterName":"constance","Location":"Head","Type":"String","ParameterCatalog":"CONSTANT"}]
&ServiceParametersMap=[{"ServiceParameterName":"age","RequestParameterName":"age"},{"ServiceParameterName":"sex","RequestParameterName":"sex"},{"ServiceParameterName":"userId","RequestParameterName":"userId"},{"ServiceParameterName":"clientIp","RequestParameterName":"CaClientIp"},{"ServiceParameterName":"constance","RequestParameterName":"constance"}]
&ResultType=HTML
&ResultSample=200
&<公共请求参数>
XML
格式
<CreateApiResponse>
<RequestId>CEF72CEB-54B6-4AE8-B225-F876FF7BA984</RequestId>
<ApiId>8afff6c8c4c6447abb035812e4d66b65</ApiId>
</CreateApiResponse>
JSON
格式
{
"RequestId":"6C87A26A-6A18-4B8E-8099-705278381A2C",
"ApiId":"8afff6c8c4c6447abb035812e4d66b65"
}
在文档使用中是否遇到以下问题
更多建议
匿名提交