All Products
Search
Document Center

DataWorks:CreateDataServiceApi

Last Updated:Nov 21, 2024

Creates an API.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
TenantIdlongNo

The tenant ID.

10001
ProjectIdlongYes

The workspace ID.

10000
ApiNamestringYes

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

GroupIdstringYes

The business process ID.

ApiModeintegerYes

The type of the API. Valid values: 0, 1, and 2. The value 0 indicates that the API is generated in wizard mode. The value 1 indicates that the API is generated in script mode. The value 2 indicates that the API is generated by registration.

0
RequestMethodintegerYes

The request method of the API. Valid values: 0, 1, 2, and 3. The value 0 indicates the GET method. The value 1 indicates the POST method. The value 2 indicates the PUT method. The value 3 indicates the DELETE method. APIs generated in wizard or script mode support the GET and POST methods. APIs generated by registration support the GET, POST, PUT, and DELETE methods.

0
ResponseContentTypeintegerYes

The format in which the response of the API request is returned. Valid values: 0 and 1. The value 0 indicates the JSON format. The value 1 indicates the XML format. APIs generated in wizard or script mode support the JSON format. APIs generated by registration support the JSON and XML formats.

0
TimeoutintegerYes

The timeout period of the API request. Unit: milliseconds. Valid values: (0,30000].

10000
VisibleRangeintegerYes

The scope in which the API is visible. Valid values: 0 and 1. The value 0 indicates that the API is visible to all members in the workspace. The value 1 indicates that the API is visible only to its owner.

0
ProtocolsstringYes

The protocol used by the API. Valid values: 0 and 1. The value 0 indicates HTTP. The value 1 indicates HTTPS. You can specify multiple protocols. Separate them with commas (,).

0,1
WizardDetailsstringNo

The details of the API generated in wizard mode. For more information, see the WizardDetails parameter returned by the GetDataServiceApi operation.

{"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"}]}
ScriptDetailsstringNo

The details of the API generated in script mode. For more information, see the scriptDetails parameter returned by the GetDataServiceApi operation.

{"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"}]}
RegistrationDetailsstringNo

The details of the API generated by registration. For more information, see the registrationDetails parameter returned by the GetDataServiceApi operation.

{"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"}
ApiPathstringYes

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

/test/1
ApiDescriptionstringYes

The description of the API.

FolderIdlongNo

The ID of the folder used to store the API. The ID of the root folder in a business process is 0. The ID of the folder created by a user must be greater than 0.

0
SqlModelongNo
  • The SQL mode. Valid values: 0: The basic mode is used.
  • 1: Mybatis is used.
0
ResourceGroupIdlongNo

The ID of the exclusive resource group.

3242432423
RequestContentTypeintegerNo

The format of the data to be requested. Valid values:

  • 0: XML format
  • 1: JSON format
  • 2: form format
0

Response parameters

ParameterTypeDescriptionExample
object
HttpStatusCodeinteger

The HTTP status code.

200
Datalong

The ID of the API.

100003
ErrorMessagestring

The error message.

The connection does not exist.
RequestIdstring

The request ID.

0000-ABCD-EFG****
ErrorCodestring

The error code.

Invalid.Tenant.ConnectionNotExists
Successboolean

Indicates whether the request was successful.

true

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError messageDescription
403Forbidden.AccessAccess is forbidden. Please first activate DataWorks Enterprise Edition or Flagship Edition.No permission, please authorize
429Throttling.ApiThe request for this resource has exceeded your available limit.-
429Throttling.SystemThe DataWorks system is busy. Try again later.-
429Throttling.UserYour request is too frequent. Try again later.-
500InternalError.SystemAn internal system error occurred. Try again later.-
500InternalError.UserId.MissingAn internal system error occurred. Try again later.-

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-10-10The Error code has changedView Change Details
2023-03-31The Error code has changed. The request parameters of the API has changedView Change Details
2023-03-02The Error code has changed. The request parameters of the API has changedView Change Details