Call CreateDataServiceApi create a dataservice studio API.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Required CreateDataServiceApi

The operation that you want to perform.

ApiDescription String Required Test API description

The description of the API operation.

ApiMode Integer Yes 0

The type of the API. Valid values: 0 (Wizard API), 1 (Script API), and 2 (registration API).

ApiName String Required Test API

The API name. The name must be 4 to 50 characters in length and can contain letters, digits, and underscores (_). It must start with a letter.

ApiPath String Required /test/1

The API path. The API path can contain letters, digits, underscores (_), and hyphens (-). It must start with a forward slash (/) and cannot exceed 200 characters.

GroupId String Required workflow ID

workflow ID

ProjectId Long Yes 10000

The ID of the DataWorks workspace.

Protocols String Required 0,1

The protocol used by the API. Valid values: 0(HTTP) and 1(HTTPS). You can enter multiple values and separate them with commas (,).

RegionId String Required cn-shanghai

The ID of the region where your project resides.

RequestMethod Integer Yes 0

The API request method. You can select 0(GET), 1(POST), 2(PUT), or 3(DELTE). The Wizard and script APIs support GET and POST. The registration API supports GET, POST, PUT, and DELETE.

ResponseContentType Integer Yes 0

The type of the data to be returned for the API. Valid values: 0(JSON) and 1(XML). JSON is supported for Wizard and script APIs, and JSON and XML are supported for registration APIs.

TenantId Long Yes 10001

The ID of the tenant.

Timeout Integer Yes 10000

The timeout period. Unit: milliseconds. Valid values:

(0, 30000]. )
VisibleRange Integer Yes 0

Visible range. Optional enumeration values include 0 (workspace) and 1 (private).

WizardDetails String No {"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"}]}

For more information about the wizard API, see the JSON String in the wizardDetails field of the GetDataServiceApi API.

ScriptDetails String No {"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"}]}

For more information about the script API, see the JSON String in scriptDetails GetDataServiceApi.

RegistrationDetails String No {"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"}

For more information about how to register an API, see the JSON String of GetDataServiceApi API registrationDetails.

FolderId Long No 0

The ID of the destination folder where the API operation is created. The root folder ID of workflow is equal to 0. The ID of the user-created folder is greater than 0.

Response parameters

Parameter Type Example Description
Data Long 100003

The ID of the API.

ErrorCode String 0

The error code.

ErrorMessage String Valid

The returned message.

HttpStatusCode Integer 200

The HTTP status code.

RequestId String 0000-ABCD-EFG****

The unique ID of the request.

Success Boolean true

Indicates whether the call is successful.

Examples

Sample requests

http(s)://[Endpoint]/? Action=CreateDataServiceApi
&ApiDescription=Test API description
&ApiMode=0
&ApiName=Test API name
&ApiPath=/test/1
&GroupId=group ID
&ProjectId=10000
&Protocols=0,1
&RegionId=cn-shanghai
&RequestMethod=0
&ResponseContentType=0
&TenantId=10001
&Timeout=10000
&VisibleRange=0
&<Common request parameters>

Sample success responses

XML format

<RequestId>0000-ABCD-EFG****</RequestId>
<HttpStatusCode>200</HttpStatusCode>
<Data>100003</Data>
<ErrorCode>0</ErrorCode>
<ErrorMessage> normal </ErrorMessage>
<Success>true</Success>

JSON format

{
    "RequestId": "0000-ABCD-EFG****",
    "HttpStatusCode": 200,
    "Data": 100003,
    "ErrorCode": 0,
    "ErrorMessage": "normal",
    "Success": true
}

Error code

HttpCode Error code Error message Description
403 Forbidden.Access Access is forbidden. Activate DataWorks first. Your access is restricted, possibly because you have not activated DataWorks.
500 InternalError.System An internal system error occurred. Try again later. An internal system error occurred. Please try again later.
500 InternalError.UserId.Missing An internal system error occurred. Try again later. An internal system error occurred. Please try again later.
403 ResourceNotAuthorized.Api You are not authorized to access the resources. You cannot access resources without authorization.
429 Throttling.Api The request for this resource has exceeded your available limit. The request for the resource exceeds your available upper limit.
429 Throttling.System The DataWorks system is busy. Try again later. DataWorks the system is busy, please try again later.
429 Throttling.User Your request is too frequent. Try again later. Your request is too frequent, please try to slow down the request speed.

For a list of error codes, visit the API Error Center.