API Update Media Entry (name and description)

Hi,

We have created an Integration between Picturepark DAM and Kaltura. It is working fine except one thing. We cannot update name and description of a media entry. Updating custom metadata and the media entry itself is working fine.

I do the following:

private void UpdateMetadataToKaltura(KeyValuePair<int, CustomAsset> asset)
{
KalturaClient client = GetKalturaClient(KalturaSessionType.USER);
KalturaMediaEntry mediaEntry = GetKalturaMediaEntry(asset.Value.KalturaID);
string categories = GetCategoryIds(client, asset.Value);
string tags = GetStringFromList(asset.Value.Tags);

        mediaEntry.Name = asset.Value.Title;
        mediaEntry.RedirectEntryId = asset.Value.AssetId.ToString();
        mediaEntry.Description = asset.Value.Description;
        mediaEntry.CategoriesIds = categories;
        mediaEntry.Tags = tags;
        mediaEntry.SearchProviderType = KalturaSearchProviderType.KALTURA; 
       
        client.MediaService.Update(asset.Value.KalturaID, mediaEntry);

    }

The code above throw an error the "Invalid entry schedule dates"
I don`t know what to do there, I just want to change the name and Description and would like to keep everything else like it is.

Has anyone an idea?

Thanks in advance!
Stefan

Hi Stefan,

Firstly, you seem to have some typos as far as uppercase vs. lowercase goes, in the code you attached above, for instance:

        mediaEntry.Name = asset.Value.Title;

Should be:

mediaEntry.name = asset.Value.Title ;

Also, mediaEntry.searchProviderType cannot be updated, but, not sure why you need to update it?

Below is a full example of a class that updates the name, description, category IDs and tags, in the example, the values are hard coded in the code just to make it as simple as possible but of course you need to change that.

import com.kaltura.client.enums.*;
import com.kaltura.client.types.*;
import com.kaltura.client.services.*;
import com.kaltura.client.KalturaApiException;
import com.kaltura.client.KalturaClient;
import com.kaltura.client.KalturaConfiguration;
import chunkedupload.ChunkedUpload;

public class UpdateEntry { 
        public static void main(String[] argv){
                try{
                        if (argv.length < 4){
                                System.out.println("Usage: <service URL> <partner ID> <partner admin secret> <entryId>\n");
                                System.exit (1);
                        }
                        try{
                                KalturaConfiguration config = new KalturaConfiguration();
                                config.setEndpoint(argv[0]);
                                KalturaClient client = new KalturaClient(config);

                                String secret = argv[2];
                                String userId = null;
                                int partnerId = Integer.parseInt(argv[1]);
                                String privileges = null;
                                KalturaSessionService sessionService = client.getSessionService();
                                String ks = client.generateSessionV2(secret, null, KalturaSessionType.USER, partnerId, 86400, "");
                                // comment the call to generateSessionV2() and uncomment the 2 lines below when working with older Kaltura server versions:
                                //String ks = client.generateSession(secret, "v2o", KalturaSessionType.ADMIN, partnerId);
                                client.setSessionId(ks);
                                System.out.println(ks);
                                String entryId = argv[3];
                                KalturaMediaEntry mediaEntry = new KalturaMediaEntry();
                                mediaEntry.name = "blah";
                                mediaEntry.description = "blah blah";
                                mediaEntry.tags = "aha";
                                mediaEntry.categoriesIds = "705,700";
                                Object result = client.getMediaService().update(entryId, mediaEntry);
                        } catch (KalturaApiException e) {
                                    e.printStackTrace();
                        }
                } catch (Exception exc) {
                exc.printStackTrace();
        }
        }
}

You can compile it from the command line by using:

$ javac -cp .:KalturaClient-3.3.1.jar:httpclient-4.2.3.jar:commons-httpclient-3.1.jar:log4j-1.2.15.jar:json-20090211.jar UpdateEntry.java 

And then run it with:

$ java -cp .:KalturaClient-3.3.1.jar:httpclient-4.2.3.jar:commons-httpclient-3.1.jar:log4j-1.2.15.jar:json-20090211.jar:commons-codec-1.6.jar:commons-logging-1.1.1.jar UpdateEntry  <service URL> <partner ID> <partner admin secret> <entryId>

For SaaS, service URL should be https://www.kaltura.com, if it is self hosted then you should provide your own endpoint.

Hi Jess,

Thanks for your prompt answer!
In C# it`s correct that “Name” starts uppercase. This is not the problem.

I dont want to update the SearchProviderType, but when I dont set it I get the following error:
[14:53:05] Error: Invalid enumeration value “0” for parameter “searchProviderType”, expecting enumeration type "KalturaSearchProviderType"
Everything else is the same as in your example.

Do you have another idea what it can be?

Thanks
Stefan

Hi Stefan,

Sorry, hadn’t noticed it is C#, for that, this function works correctly for me:

        static void UpdateEntry()
        {
            KalturaClient client = new KalturaClient(GetConfig());
            client.KS = client.GenerateSession(ADMIN_SECRET, USER_ID, KalturaSessionType.ADMIN, PARTNER_ID, 86400, "");
            KalturaMediaEntry mediaEntry = new KalturaMediaEntry();
            mediaEntry.Name = "Test";
            mediaEntry.Description = "Testing...";
            mediaEntry.Tags = "someTag1";
            mediaEntry.CategoriesIds = "705,700";
            mediaEntry = client.MediaService.Update("0_ogrgf4xp", mediaEntry);

        }

Easiest way to try it is to add it to KalturaClientTester/KalturaClientTester.cs and call it from there as well.

in KalturaClientTester/KalturaClientTester.cs, you need to set

                private const int PARTNER_ID = ; //enter your partner id
                private const string ADMIN_SECRET = ""; //enter your admin secret
                private const string SERVICE_URL = "";

And of course, change “0_ogrgf4xp” to a valid entry ID for your partner and “705,700” to valid cat IDs before running it.

You haven’t mentioned which version of the clientlibs you are using or what server version you’re using.
If your server version is 10.11.0 and above, I recommend you take the corresponding branch from:

If this does not work for you, please provide a simple standalone code that I can run myself and the server version you are working against so I can further help you.
In that standalone code, please provide the actual literal values you are using, minus the secret of course, which you should never provide anyone with:)