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

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

ParameterTypeRequiredExampleDescription
ActionStringYesCreateResourceFile

The operation that you want to perform.

ProjectIdLongYes10000

The DataWorks workspace ID. You can log on to the DataWorks console and go to the Workspace page to obtain the workspace ID. You must configure this parameter to specify the DataWorks workspace to which the operation is applied.

FileFolderPathStringYesWorkflow/1/MaxCompute/Folder 1/Folder 2

The path of the file.

FileNameStringYesFile name

The name of the file.

FileTypeIntegerYes10

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.

FileDescriptionStringNoFile description

The description of the file.

OwnerStringNo1000000000001

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.

ContentStringNoSHOW 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.

ResourceFileStringNohttp://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.

OriginResourceNameStringYesorigin_file_name.sql

The name of the original resource file.

UploadModeBooleanNofalse

The upload mode of MaxCompute file resources. This parameter takes effect only for MaxCompute file resources. Valid values: true and false. The value true indicates the resource upload and download mode. The value false indicates the online editing mode.

RegisterToCalcEngineBooleanYesfalse

Specifies whether to upload the resource file to a desired compute engine.

StorageURLStringNooss://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

ParameterTypeExampleDescription
DataLong1000001

The ID of the file that was created.

RequestIdString0000-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 codeError codeError messageDescription
429Throttling.ApiThe request for this resource has exceeded your available limit.The number of requests for the resource has exceeded the upper limit.
429Throttling.SystemThe DataWorks system is busy. Try again later.The DataWorks system is busy. Try again later.
429Throttling.UserYour request is too frequent. Try again later.Excessive requests have been submitted within a short period of time. Try again later.
500InternalError.SystemAn internal system error occurred. Try again later.An internal error occurred. Try again later.
500InternalError.UserId.MissingAn internal system error occurred. Try again later.An internal error occurred. Try again later.

For a list of error codes, see Service error codes.