Creates an API.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | CreateDataServiceApi | The operation that you want to perform. Set the value to CreateDataServiceApi. |
TenantId | Long | No | 10001 | The tenant ID. |
ProjectId | Long | Yes | 10000 | The workspace ID. |
ApiName | String | Yes | API name | 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. |
GroupId | String | Yes | Business process ID | The business process ID. |
ApiMode | Integer | Yes | 0 | 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. |
RequestMethod | Integer | Yes | 0 | 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. |
ResponseContentType | Integer | Yes | 0 | 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. |
Timeout | Integer | Yes | 10000 | The timeout period of the API request. Unit: milliseconds. Valid values: (0,30000]. ) |
VisibleRange | Integer | Yes | 0 | 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. |
Protocols | String | Yes | 0,1 | 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 (,). |
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"}]} | The details of the API generated in wizard mode. For more information, see the WizardDetails parameter returned by the GetDataServiceApi operation. |
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"}]} | The details of the API generated in script mode. For more information, see the ScriptDetails parameter returned by the GetDataServiceApi operation. |
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"} | The details of the API generated by registration. For more information, see the RegistrationDetails parameter returned by the GetDataServiceApi operation. |
ApiPath | String | Yes | /test/1 | 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 (/). |
ApiDescription | String | Yes | API description | The description of the API. |
FolderId | Long | No | 0 | 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. |
SqlMode | Long | No | 0 |
|
ResourceGroupId | Long | No | 3242432423 | The ID of the exclusive resource group. |
RequestContentType | Integer | No | 0 | The format of the data to be requested. Valid values:
|
Response parameters
Parameter | Type | Example | Description |
HttpStatusCode | Integer | 200 | The HTTP status code. |
Data | Long | 100003 | The ID of the API. |
ErrorMessage | String | The connection does not exist. | The error message. |
RequestId | String | 0000-ABCD-EFG**** | The request ID. |
ErrorCode | String | Invalid.Tenant.ConnectionNotExists | The error code. |
Success | Boolean | true | Indicates whether the request was successful. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateDataServiceApi
&TenantId=10001
&ProjectId=10000
&ApiName=API name
&GroupId=Business process 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 description
&FolderId=0
&SqlMode=0
&ResourceGroupId=3242432423
&RequestContentType=0
&<Common request parameters>
Sample success responses
XML
format
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
format
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
}
Error codes
HTTP status code | Error code | Error message | Description |
429 | Throttling.Api | The request for this resource has exceeded your available limit. | The number of requests for the resource has exceeded the upper limit. |
429 | Throttling.System | The DataWorks system is busy. Try again later. | The DataWorks system is busy. Try again later. |
429 | Throttling.User | Your request is too frequent. Try again later. | Excessive requests have been submitted within a short period of time. Try again later. |
500 | InternalError.System | An internal system error occurred. Try again later. | An internal error has occurred. Try again later. |
500 | InternalError.UserId.Missing | An internal system error occurred. Try again later. | An internal error has occurred. Try again later. |
For a list of error codes, see Service error codes.