kalturaCategory add with custom metadata values

I want to add categories using the add action in the category api
the problem is that I do not see how I can put values in my custom metadata schema for categories that I have.
Can someone help me with that? I can put values for description, tags etc but not my custom meta data.

Hi Petros,

First, you need to create a custom metadata schema that applies to categories.
This can be done from KMC->Settings->Custom Data->Add new shcema
make sure you choose ‘Categories’ in the ‘Apply To’ selectbox, default is entries.

Same thing can be done from the API with:

$metadataProfile=new KalturaMetadataProfile();
$metadataProfile->name = $profile_name;
$metadataProfile->createMode = KalturaMetadataProfileCreateMode::API;
$metadataProfile->systemName = $profile_name;
$metadataProfile->metadataObjectType = KalturaMetadataObjectType::CATEGORY;
$results = $client->metadataProfile->add($metadataProfile, $xsdData, $viewsData);

This example is PHP but any of the clients can do the same.

Then, to set data, you need:

$objectType = KalturaMetadataObjectType::CATEGORY;
$objectId = $category_id;
$xmlData = '<metadata> <'.METADATA_FIELD.'>Yes</'.METADATA_FIELD.'></metadata>';
$result = $metadataPlugin->metadata->add($metadata_profile_id, $objectType, $objectId, $xmlData);

You can also look at this example of working with metadata here:

That one works with entry object rather than categories but the idea is the same.