名前を指定してメタデータテンプレートを取得

get
https://api.box.com/2.0
/metadata_templates/:scope/:template_key/schema

scopetemplateKeyの値でメタデータテンプレートを取得します。

テンプレートのscopetemplateKeyを調べるには、会社のすべてのテンプレートまたはグローバルテンプレートのリストを取得するか、ファイルまたはフォルダに適用されているすべてのテンプレートのリストを取得します。

リクエスト

bearer [ACCESS_TOKEN]
application/json

パスパラメータ

stringパス内必須
global

メタデータテンプレートのスコープ

次の値のいずれか1つ: global,enterprise

stringパス内必須
properties

メタデータテンプレートの名前

レスポンス

scopeおよびtemplateの名前と一致するメタデータテンプレートを返します。

リクエストパラメータのいずれかが無効な場合に返されます。

  • bad_request: テンプレートのスコープが認識されていない場合によく返されます。scopeの値として必ずenterpriseまたはglobalを使用してください。

指定されたscopeおよびtemplate_keyを持つテンプレートが見つからない場合に返されます。

予期しないクライアントエラー。

get
名前を指定してメタデータテンプレートを取得
このドキュメント内で一部のAPIを試せるようになりました。
ログイン

リクエストの例

cURL
curl -i -X GET "https://api.box.com/2.0/metadata_templates/enterprise/blueprintTemplate/schema" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
.NET
BoxMetadataTemplate template = await client.MetadataManager
    .GetMetadataTemplate("enterprise", "marketingCollateral");
Java
MetadataTemplate template = MetadataTemplate.getMetadataTemplate(api, "templateName");
Python
template = client.metadata_template('enterprise', 'employeeRecord').get()
print(f'The {template.displayName} template has {len(template.fields)} fields')
Node
client.metadata.getTemplateSchema('enterprise', 'vcontract')
	.then(template => {
		/* template -> {
			id: '17f2d715-6acb-45f2-b96a-28b15efc9faa',
			templateKey: 'vcontract',
			scope: 'enterprise_12345',
			displayName: 'Vendor Contract',
			hidden: true,
			fields: 
			[ { type: 'date',
				key: 'signed',
				displayName: 'Date Signed',
				hidden: false },
				{ type: 'string',
				key: 'vendor',
				displayName: 'Vendor',
				hidden: false },
				{ type: 'enum',
				key: 'fy',
				displayName: 'Fiscal Year',
				options: 
					[ { key: 'FY17' },
					{ key: 'FY18' },
					{ key: 'FY19' } ],
				hidden: false } ] }
		*/
	});
iOS
client.metadata.getTemplateByKey(
    scope: "enterprise",
    templateKey: "personnelRecord"
) { (result: Result<MetadataTemplate, BoxSDKError>) in
    guard case let .success(template) = result {
        print("Error retrieving metadata template")
        return
    }

    print("Metadata template has \(template.fields?.count) fields")
}

レスポンスの例

{
  "id": "58063d82-4128-7b43-bba9-92f706befcdf",
  "type": "metadata_template",
  "copyInstanceOnItemCopy": true,
  "displayName": "Product Info",
  "fields": [
    {
      "type": "string",
      "key": "category",
      "displayName": "Category",
      "description": "The category",
      "hidden": true,
      "options": [
        {
          "key": "Category 1",
          "id": "45dc2849-a4a7-40a9-a751-4a699a589190"
        }
      ],
      "id": "822227e0-47a5-921b-88a8-494760b2e6d2"
    }
  ],
  "hidden": true,
  "scope": "enterprise_123456",
  "templateKey": "productInfo"
}