Updated on 2025-12-25 GMT+08:00

Creating a Metadata (2.1.18)

Function

This API is used to create a metadata file.

URI

POST /v2/{project_id}/graphs/metadatas

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID. For details about how to obtain a project ID, see Obtaining a Project ID.

Constraints

N/A

Range

The value can contain up to 64 characters. Only letters and digits are allowed.

Default Value

N/A

Request Parameters

Table 2 Request header parameter

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token. It is used to obtain the permission to call APIs. For how to obtain the token, see Authentication. (The token is the value of X-Subject-Token in the response header.)

Constraints

N/A

Range

N/A

Default Value

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

metadata_path

Yes

String

Definition

Metadata storage path.

Constraints

N/A

Range

N/A

Default Value

N/A

name

Yes

String

Definition

Metadata file name.

Constraints

The value can contain up to 64 characters. Only letters, digits, and underscores (_) are allowed.

Range

N/A

Default Value

N/A

description

Yes

String

Definition

Metadata file description.

Constraints

N/A

Range

N/A

Default Value

N/A

is_overwrite

Yes

Boolean

Definition

Whether to overwrite existing files.

Constraints

N/A

Range

  • true: Overwrite.
  • false: Do not overwrite.

Default Value

N/A

ges_metadata

Yes

ges_metadata object

Definition

Object that stores message information for metadata.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 4 ges_metadata

Parameter

Mandatory

Type

Description

labels

Yes

Array of labels objects

Definition

Label list.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 5 labels

Parameter

Mandatory

Type

Description

name

No

String

Definition

Label name.

Constraints

N/A

Range

N/A

Default Value

N/A

properties

No

Array of Map<String,String> objects

Definition

Label property map.

Constraints

N/A

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

id

String

Definition

Metadata file ID.

Range

N/A

name

String

Definition

Metadata file name.

Range

N/A

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Definition

System prompt.

  • If the execution succeeds, this parameter may be left blank.
  • If the execution fails, this parameter is used to display the error code.

Range

N/A

error_msg

String

Definition

System prompt.

  • If the execution succeeds, this parameter may be left blank.
  • If the execution fails, this parameter is used to display the error message.

Range

N/A

Example Request

Add metadata. The metadata is stored in devdata/unionsdk/unionsdk_test.xml. The metadata does not overwrite existing data, the metadata name is unionsdk_test, and the metadata description is test.

POST https://{Endpoint}/v2/{project_id}/graphs/metadatas

{
  "metadata_path" : "devdata/unionsdk/unionsdk_test.xml",
  "is_overwrite" : false,
  "name" : "unionsdk_test",
  "description": " test",
  "ges_metadata" : {
    "labels" : [ {
      "name" : "friends"
    }, {
      "name" : "movie",
      "properties" : [ {
        "dataType" : "string",
        "name" : "ChineseTitle",
        "cardinality" : "single"
      }, {
        "dataType" : "int",
        "name" : "Year",
        "cardinality" : "single"
      }, {
        "dataType" : "string",
        "name" : "Genres",
        "cardinality" : "set"
      } ]
    }, {
      "name" : "user",
      "properties" : [ {
        "dataType" : "string",
        "name" : "ChineseName",
        "cardinality" : "single"
      }, {
        "typeName1" : "F",
        "typeName2" : "M",
        "typeNameCount" : "2",
        "dataType" : "enum",
        "name" : "Gender",
        "cardinality" : "single"
      }, {
        "typeName1" : "Under 18",
        "typeName2" : "18-24",
        "typeName3" : "25-34",
        "typeName4" : "35-44",
        "typeNameCount" : "7",
        "dataType" : "enum",
        "name" : "Age",
        "typeName5" : "45-49",
        "typeName6" : "50-55",
        "cardinality" : "single",
        "typeName7" : "56+"
      }, {
        "dataType" : "string",
        "name" : "Occupation",
        "cardinality" : "single"
      }, {
        "dataType" : "char array",
        "name" : "Zip-code",
        "maxDataSize" : "12",
        "cardinality" : "single"
      } ]
    }, {
      "name" : "rate",
      "properties" : [ {
        "dataType" : "int",
        "name" : "Score",
        "cardinality" : "single"
      }, {
        "dataType" : "date",
        "name" : "Datetime",
        "cardinality" : "single"
      } ]
    } ]
  }
}

Example Response

Status code: 200

Example response for a successful request

{
  "id" : "ff8080815f9a3c84015f9a438ff70001",
  "name" : "unionsdk_test"
}

Status code: 400

Example response for a failed request

{
  "error_msg" : "The metadata file already exists.",
  "error_code" : "GES.2067"
}

Status Codes

Return Value

Description

400 Bad Request

Request error.

401 Unauthorized

Authorization failed.

403 Forbidden

No operation permissions.

404 Not Found

No resources found.

500 Internal Server Error

Internal server error.

503 Service Unavailable

Service unavailable.