Missing Parameter from MediaUpdate Service request

Hey all,

I am debugging an issue that seems to have cropped up in our Kaltura environement. We have C# app that interacts with our Kaltura instance. The kaltura version is Mercury-13.9.0. API version on the client is 3.3.0. Client Tag is dotnet:17-12-28

Consider this chunk of code. Assume that KalturaWrapper.GetClient() returns a functioning client object.

            Client client;
            client = KalturaWrapper.Instance.GetClient();
            client.ClientTag = "HDRTV-EditVideo";
            MediaEntry editentry = new MediaEntry();
            editentry.Name = txtName.Text;
            editentry.Description = txtDescription.Text;
            editentry.Tags = txtTags.Text;
            editentry.Categories = ddlCategory.SelectedValue;
            Exception error = null;
            MediaEntry response = new MediaEntry();
            bool done = false;
            OnCompletedHandler<MediaEntry> handler = new OnCompletedHandler<MediaEntry>(
            (MediaEntry result, Exception e) =>
            {
                response = (MediaEntry)result;
                done = true;

            });
            
            MediaUpdateRequestBuilder request = MediaService.Update(videoid.Value,editentry);
            
            request.SetCompletion(handler);
            request.Execute(client);

            while (!done) { Thread.Sleep(1); }

            //Update the local cache object with the changes too. 
            KalturaWrapper.Instance.ForceBuildCache();


            lblStatus.Text = "File edited successfully. (ID=" + response.Id + ")";

What I am seeing is an Exception in the handler routine, saying that I am missing the entryId parameter in the request. I can’t see where I am missing this. I’ve verified via debugging that videoid.Value does contain the right video ID.

I searched issues on github but I can’t really find an issue on this. I know this has tested as working previously so I’m kind of at a loss here as to what the problem may be.

In case it provides more information, I enabled some Client library logging. Here is what is logged when the update request is submitted. The first few fields here are my c# app specific, so they can be ignored in this context.

Trace,Information,6000,url: [http://hostname-redacted/api_v3/service/media/action/update]
Trace,Information,6000,full reqeust data: [{"apiVersion":"3.3.0","clientTag":"dotnet:17-12-28","entryId":"0_ct3a8t3g","format":2,"kalsig":"d1ba762f7106fff8dd9891c5b1ad1ccd","ks":"KS-redacted","mediaEntry":{"categories":"ITG","description":"Description","name":"Name","objectType":"KalturaMediaEntry","tags":"Tag"}}]
Trace,Information,6000,result (serialized): <?xml version="1.0" encoding="utf-8"?><xml><result><error><code>MISSING_MANDATORY_PARAMETER</code><message>Missing parameter &quot;entryId&quot;</message><objectType>KalturaAPIException</objectType><args><item><objectType>KalturaApiExceptionArg</objectType><name>PARAM_NAME</name><value>entryId</value></item></args></error></result><executionTime>0.0020668506622314</executionTime></xml>
Trace,Information,6000,execution time for [/service/media/action/update]: [00:00:00.2073153]

Hi @david.hahn1,

In your code, I see:

MediaUpdateRequestBuilder request = MediaService.Update(videoid.Value,editentry);

but I don’t see that videoid is set anywhere…

Generally speaking, when debugging failing requests, start by locating the request in /opt/kaltura/log/kaltura_api_v3.log and inspecting the params passed to the endpoint.

Hi @jess

I forgot to mention a few things.

  1. videoid.value does contain a valid entryID. This isn’t in the code example, but I’ve verified that it’s true. I’ve also tried hard-coding a entry ID in the Update call to see if the behavior changes It does not.

  2. When I consult the Kaltura_api_v3.log for more information, I don’t see any information relating to the request. I’ve altered the client tag to make finding the appropriate entries in the log but that client tag does not appear in the api log.

  3. I’ve used Fiddler locally to examine the http traffic between my local dev server and the kaltura servers. I can see the request to the update endpoint. the request looks correct. There is an entryId parameter

Here is the body of the request. I am just noticing that the request is missing some closing brackets. If manually place them in the request, it seems to actually work.

POST http://kaltura-prod.intranet.hdr/api_v3/service/media/action/update HTTP/1.1
Accept: application/xml
Content-Type: application/json
Host: kalturahost.domain.hdr
Content-Length: 782
Expect: 100-continue
Accept-Encoding: gzip, deflate
Pragma: akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-true-cache-key, akamai-x-get-ssl-client-session-id, akamai-x-serial-no, akamai-x-get-request-id

{“apiVersion”:“3.3.0”,“clientTag”:“TV-EditVideo”,“entryId”:“0_ct3a8t3g”,“format”:2,“kalsig”:“kalsighere”,“ks”:“ks-redacted”,“mediaEntry”:{“categories”:“category”,“description”:“description”,“name”:“video name”,“objectType”:“KalturaMediaEntry”,“tags”:“tags”

The response looks like this

<?xml version="1.0" encoding="utf-8"?><xml><result><error><code>MISSING_MANDATORY_PARAMETER</code><message>Missing parameter &quot;entryId&quot;</message><objectType>KalturaAPIException</objectType><args><item><objectType>KalturaApiExceptionArg</objectType><name>PARAM_NAME</name><value>entryId</value></item></args></error></result><executionTime>0.0032801628112793</executionTime></xml>

So, doing some more investigation it seems this truncation of the request is the problem.

However, it doesn’t happen with every entry. It seem there are specific entries this happens with. I haven’t been able to narrow down what it is yet.

I thought it was a request length or body length issue, but there are other entries in which the update operation produces larger requests. These work just fine.

So, I think I figured out what’s going on here. If there is a single quote in a the description field, it seems to cause the json parsing to go bad. It could possible be in other fields too. I’m not sure.

I’m not sure if this should be treated as a bug in the c# library or what.

Alright, for those you playing the home game it appears this isn’t a problem with single quotes. It’s a problem with character sets or something similar.

I think people are copying and pasting information into my application from various sources. It seems like unexpected characters are included in this pasting and aren’t handled properly either by my code or the client library or both.

Hi @david.hahn1,

Please provide a full example for such an entry object and I’ll take a look.

Sure thing @jess. I’d feel more comfortable PM’ing you the object so I’ll go that route.

Hi @jess

I’ve been sitting on this problem for a while and am ready to try to pick it back up again. I will text you a complete example project that should help