Creates or uploads a resource file in DataStudio. The feature that is implemented by calling this operation is the same as the resource creation feature provided in the integrated development environment (IDE).
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | CreateResourceFile |
The operation that you want to perform. |
ProjectId | Long | Yes | 10000 | The DataWorks workspace ID. You can log on to the DataWorks console and go to the Work space page to obtain the workspace ID. You must configure this parameter to specify the DataWorks workspace to which the operation is applied. |
FileFolderPath | String | Yes | Workflow/1/MaxCompute/Folder 1/Folder 2 | The path of the file. |
FileName | String | Yes | File name | The name of the file. |
FileType | Integer | Yes | 10 | The type of the code for the file. Valid values: 6 (Shell), 10 (ODPS SQL), 11 (ODPS MR), 24 (ODPS Script), 99 (zero load), 221 (PyODPS 2), 225 (ODPS Spark), 227 (EMR Hive), 228 (EMR Spark), 229 (EMR Spark SQL), 230 (EMR MR), 239 (OSS object inspection), 257 (EMR Shell), 258 (EMR Spark Shell), 259 (EMR Presto), 260 (EMR Impala), 900 (real-time synchronization), 1089 (cross-tenant collaboration), 1091 (Hologres development), 1093 (Hologres SQL), 1100 (assignment), and 1221 (PyODPS 3). You can call the ListFileType operation to query the type of the code for the file. |
FileDescription | String | No | File description | The description of the file. |
Owner | String | No | 1000000000001 | The ID of the Alibaba Cloud account used by the file owner. If this parameter is not configured, the ID of the Alibaba Cloud account of the user who calls the operation is used by default. |
Content | String | No | SHOW TABLES; | The code for the file. The code format varies based on the file type. To view the code format for a specific file type, go to Operation Center, open the directed acyclic graph (DAG) of a node of the file type, right-click the node, and then select View Code. |
ResourceFile | String | No | http://bucketname1.oss-cn-shanghai.aliyuncs.com/example | The URL of the Object Storage Service (OSS) bucket to which you upload the file. The URL is provided by the POP platform. |
OriginResourceName | String | Yes | origin_file_name.sql | The name of the original resource file. |
UploadMode | Boolean | No | false | The upload mode of MaxCompute file resources. This parameter takes effect only for MaxCompute file resources. Valid values:
|
RegisterToCalcEngine | Boolean | Yes | false | Specifies whether to upload the resource file to a desired compute engine. |
StorageURL | String | No | oss://oss-cn-shanghai.aliyuncs.com/emr-test | The storage path of the resource file in a desired compute engine. This parameter takes effect only for E-MapReduce (EMR) and Cloudera's Distribution including Apache Hadoop (CDH) compute engines. In an EMR compute engine, this parameter is configured in the oss|hdfs://path/to/object format. In a CDH compute engine, this parameter is set to /user/admin/lib by default. |
Response parameters
Parameter | Type | Example | Description |
Data | Long | 1000001 | The ID of the file that was created. |
RequestId | String | 0000-ABCD-EFG | The request ID. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateResourceFile
&ProjectId=10000
&FileFolderPath=Workflow/1/MaxCompute/Folder 1/Folder 2
&FileName=File name
&FileType=10
&FileDesc=File description
&Owner=1000000000001
&Content=SHOW TABLES;
&OriginResourceName=origin_file_name.sql
&UploadMode=false
&RegisterToCalcEngine=false
&StorageUri=oss://oss-cn-chengdu-internal.aliyuncs.com/chengdu-bucketname/
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateResourceFileResponse>
<Data>1000001</Data>
<RequestId>0000-ABCD-EFG</RequestId>
</CreateResourceFileResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"Data" : 1000001,
"RequestId" : "0000-ABCD-EFG"
}
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 occurred. Try again later. |
500 | InternalError.UserId.Missing | An internal system error occurred. Try again later. | An internal error occurred. Try again later. |
For a list of error codes, see Service error codes.