调用CreateDataServiceApi创建数据服务API。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String CreateDataServiceApi

系统规定参数。取值:CreateDataServiceApi

RegionId String cn-shanghai

地域ID。

TenantId Long 10001

租户ID。

ProjectId Long 10000

工作空间的ID。

ApiName String 测试API名称

API的名称,支持汉字、英文、数字和下划线(_),且只能以英文和汉字开头,4~50个字符。

GroupId String 业务流程ID

业务流程的ID。

ApiMode Integer 0

API的类型,可选枚举值包括0(向导API)、1(脚本API)和2(注册API)。

RequestMethod Integer 0

API的请求方式,可选枚举值包括0(GET)、1(POST)、2(PUT)和3(DELTE)。向导和脚本API支持GET和POST。注册API支持GET、POST、PUT和DELETE。

ResponseContentType Integer 0

API的返回数据类型,可选枚举值包括0(JSON)和1(XML)。向导和脚本API支持JSON,注册API支持JSON和XML。

Timeout Integer 10000

超时时间,单位为毫秒(ms),取值范围为(0,30000]。

VisibleRange Integer 0

API的可见范围,包括0(工作空间)和1(私有):

  • 0(工作空间):该API对本工作空间内的所有成员可见。
  • 1(私有):该API仅对API的负责人可见,且暂不支持授权。
Protocols String 0,1

API的协议,可选枚举值包括0(HTTP)和1(HTTPS)。支持多个值,多个值之间使用英文逗号(,)分隔。

WizardDetails String {"isPagedResponse":true,"wizardConnection":{"connectionId":122786,"tableName":"person"},"wizardRequestParameters":[{"columnName":"id","defaultValue":"","exampleValue":"1","isRequiredParameter":true,"parameterDataType":2,"parameterDescription":"","parameterName":"id","parameterOperator":0,"parameterPosition":0}],"wizardResponseParameters":[{"columnName":"id","exampleValue":"11","parameterDataType":2,"parameterDescription":"","parameterName":"id"}]}

向导API的详情,请参见GetDataServiceApi接口wizardDetails字段的JSON String。

ScriptDetails String {"isPagedResponse":false,"script":"select id as id1, name as name1 from person where id=${inputid}","scriptConnection":{"connectionId":122786,"tableName":"person"},"scriptRequestParameters":[{"defaultValue":"","exampleValue":"","isRequiredParameter":true,"parameterDataType":0,"parameterDescription":"","parameterName":"inputid","parameterOperator":0,"parameterPosition":1}],"scriptResponseParameters":[{"exampleValue":"","parameterDataType":0,"parameterDescription":"","parameterName":"id1"},{"exampleValue":"","parameterDataType":0,"parameterDescription":"","parameterName":"name1"}]}

脚本API的详情,请参见GetDataServiceApi接口scriptDetails字段的JSON String。

RegistrationDetails String {"failedResultSample":"fail","registrationErrorCodes":[{"errorCode":"e1","errorMessage":"msg1","errorSolution":"sol1"},{"errorCode":"e2","errorMessage":"msg2","errorSolution":"sol2"}],"registrationRequestParameters":[{"columnName":"","defaultValue":"","exampleValue":"","isRequiredParameter":true,"parameterDataType":0,"parameterDescription":"","parameterName":"id","parameterOperator":0,"parameterPosition":1},{"columnName":"","defaultValue":"xx","exampleValue":"","isRequiredParameter":true,"parameterDataType":0,"parameterDescription":"","parameterName":"cc","parameterOperator":2,"parameterPosition":2}],"serviceContentType":1,"serviceHost":"http://www.baidu.com","servicePath":"/[uid]","serviceRequestBodyDescription":"body","successfulResultSample":"success"}

注册API的详情,请参见GetDataServiceApi接口registrationDetails字段的JSON String。

ApiPath String /test/1

API的路径,支持英文、数字、下划线(_)和连字符(-),且只能以斜线(/)开头,不能超过200个字符。

ApiDescription String 测试API描述

API的描述信息。

FolderId Long 0

创建API的目标文件夹ID,业务流程下根文件夹ID等于0,用户自建文件夹ID大于0。

返回数据

名称 类型 示例值 描述
HttpStatusCode Integer 200

HTTP状态码。

Data Long 100003

创建的API ID。

ErrorMessage String The connection does not exist.

错误信息。

RequestId String 0000-ABCD-EFG****

请求ID,一次请求的唯一标识。

ErrorCode String Invalid.Tenant.ConnectionNotExists

错误码。

Success Boolean true

调用是否成功。

示例

请求示例

http(s)://[Endpoint]/?Action=CreateDataServiceApi
&TenantId=10001
&ProjectId=10000
&ApiName=测试API名称
&GroupId=业务流程ID
&ApiMode=0
&RequestMethod=0
&ResponseContentType=0
&Timeout=10000
&VisibleRange=0
&Protocols=0,1
&WizardDetails={"isPagedResponse":true,"wizardConnection":{"connectionId":122786,"tableName":"person"},"wizardRequestParameters":[{"columnName":"id","defaultValue":"","exampleValue":"1","isRequiredParameter":true,"parameterDataType":2,"parameterDescription":"","parameterName":"id","parameterOperator":0,"parameterPosition":0}],"wizardResponseParameters":[{"columnName":"id","exampleValue":"11","parameterDataType":2,"parameterDescription":"","parameterName":"id"}]}
&ScriptDetails={"isPagedResponse":false,"script":"select id as id1, name as name1 from person where id=${inputid}","scriptConnection":{"connectionId":122786,"tableName":"person"},"scriptRequestParameters":[{"defaultValue":"","exampleValue":"","isRequiredParameter":true,"parameterDataType":0,"parameterDescription":"","parameterName":"inputid","parameterOperator":0,"parameterPosition":1}],"scriptResponseParameters":[{"exampleValue":"","parameterDataType":0,"parameterDescription":"","parameterName":"id1"},{"exampleValue":"","parameterDataType":0,"parameterDescription":"","parameterName":"name1"}]}
&RegistrationDetails={"failedResultSample":"fail","registrationErrorCodes":[{"errorCode":"e1","errorMessage":"msg1","errorSolution":"sol1"},{"errorCode":"e2","errorMessage":"msg2","errorSolution":"sol2"}],"registrationRequestParameters":[{"columnName":"","defaultValue":"","exampleValue":"","isRequiredParameter":true,"parameterDataType":0,"parameterDescription":"","parameterName":"id","parameterOperator":0,"parameterPosition":1},{"columnName":"","defaultValue":"xx","exampleValue":"","isRequiredParameter":true,"parameterDataType":0,"parameterDescription":"","parameterName":"cc","parameterOperator":2,"parameterPosition":2}],"serviceContentType":1,"serviceHost":"http://www.baidu.com","servicePath":"/[uid]","serviceRequestBodyDescription":"body","successfulResultSample":"success"}
&ApiPath=/test/1
&ApiDescription=测试API描述
&FolderId=0
&公共请求参数

正常返回示例

XML格式

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateDataServiceApiResponse>
    <HttpStatusCode>200</HttpStatusCode>
    <Data>100003</Data>
    <ErrorMessage>The connection does not exist.</ErrorMessage>
    <RequestId>0000-ABCD-EFG****</RequestId>
    <ErrorCode>Invalid.Tenant.ConnectionNotExists</ErrorCode>
    <Success>true</Success>
</CreateDataServiceApiResponse>

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "HttpStatusCode" : 200,
  "Data" : 100003,
  "ErrorMessage" : "The connection does not exist.",
  "RequestId" : "0000-ABCD-EFG****",
  "ErrorCode" : "Invalid.Tenant.ConnectionNotExists",
  "Success" : true
}

错误码

HttpCode 错误码 错误信息 描述
500 InternalError.System An internal system error occurred. Try again later. 系统内部错误,请稍后再试。
500 InternalError.UserId.Missing An internal system error occurred. Try again later. 系统内部错误,请稍后再试。
403 Forbidden.Access Access is forbidden. Please first activate DataWorks Enterprise Edition or Flagship Edition. 您被限制访问,请开通DataWorks企业版或旗舰版。
429 Throttling.Api The request for this resource has exceeded your available limit. 对该资源的请求已超过您的可用上限。
429 Throttling.System The DataWorks system is busy. Try again later. DataWorks系统繁忙,请稍后再试。
429 Throttling.User Your request is too frequent. Try again later. 您的请求过于频繁,请尝试放缓请求速度。

访问错误中心查看更多错误码。