Retreiving Entry Related Files Through Kwidget

Can anyone provide a working Javascript example showing how to retreive an entry related file url through the kwidget api?

I’ve tried basing my code on the documentation I found on this with no success. Closest I got was to retreive a empty “KalturaFileAssetListResponse”.

Right now code looks like this:

    kalturaConf = {
        "wid": "_" + self.params.kalturainfo.partnerid,
        "uiconf_id": self.params.kalturainfo.playerid
    }
    requestObject = [
        {
            "service": "fileAsset",
            "action": "list",
            "filter": {
                "advancedSearch": {
                    "objectType": "KalturaCatalogItemAdvancedFilter"
                },
                "objectType": "KalturaFileAssetFilter",
                "fileAssetObjectTypeEqual": "2",
                "objectIdEqual": "0_8hlpfa75", // Related file ID
            }
        }
    ]
    new kWidget.api(kalturaConf).doRequest(requestObject, function(result){console.log(result)});

I downloaded the Kaltura js libraries (https://www.kaltura.com/api_v3/testme/client-libs.php) and followed the example found here: https://developer.kaltura.com/console/service/fileAsset/action/get

But I’m getting this error: KalturaFileAssetService.get is not a function

This example references file “KalturaFullClient.min.js” but there is no such file in the downloaded librarie. Only KalturaClient.js. I wonder if the example is out of date.

Code used:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="js/KalturaClientBase.js"></script>
<script src="js/KalturaClient.js"></script>
<script src="js/KalturaServices.js"></script>
<script>
var config = new KalturaConfiguration();
config.serviceUrl = self.params.kalturainfo.server;
var client = new KalturaClient(config);
var id = 0;

KalturaFileAssetService.get(id)
.execute(client, function(success, results) {
if (!success || (results && results.code && results.message)) {
console.log('Kaltura Error', success, results);
} else {
console.log('Kaltura Result', results);
}
});
</script>

Help :slightly_frowning_face:

I feel like I’m just talking to myself here. I think I just saw a ball of hay fly by… :wink:

I was able to get it working finally.

Code:

var requestObject = [
                {
                    "service": "attachment_attachmentasset",
                    "action": "getUrl",
                    "id": '0_8hlpfa75' // Asset ID
                }
            ]
            new kWidget.api(kalturaConfig).doRequest( requestObject, function( result ){ console.log(result) });