HTTP request to attach uploadToken to mediaEntry

Hi,
I am trying to integrate Kaltura with a media asset management platform that has the ability to post HTTP requests. The goal is to push content from this MAM directly to Kaltura through the API. Since the platform has its own workflow scripting language that allows me to send HTTP requests, the goal is to use the platform to do the requests needed to push content to Kaltura, rather than write an application in a language such as java, php, python, etc. Using a combination of basic HTTP requests in the MAM platform and curl commands, I am able to successfully create a session, create a media entry, create an upload token, and upload a file using that token. I can see the media entry in the KMC Content tab. However I’m not having any luck attaching the uploaded file to the media entry, so the entry shows no video. I can do this just fine in the TestMe console, but the console only shows me code samples in programming language formats rather than showing me the actual HTTP request that was made to Kaltura, so I don’t know what the request should be or what I’m doing wrong. Basically I need to know how I can do this in curl. Please note: using the provided Kaltura client libraries is not an option here… please don’t make suggestions that would require using the libraries and writing code in a programming language as I would like to keep the workflow native to the MAM platform. Here’s what my request looks like:

POST "http://www.kaltura.com/api_v3/?ks=${ks}&service=media&action=addContent&entryId=${entryId}&KalturaUploadedFileTokenResource:token=${tokenId}&format=1"

I am not getting any errors in the response. The media entry I created is there in the KMC Content area, When I upload the file with the token, I get a response that shows me the file size and statistics so it looks like the file was uploaded… I just can’t get it to attach to the media entry. Can someone show me what an actual HTTP request would look like to attach an uploadTokenResource to a mediaEntry? Thanks!!

Hello,

How did you generate the token?
Basically, the requests you should make are:
api_v3/index.php?service=uploadtoken&action=add
api_v3/index.php?service=uploadtoken&action=upload
api_v3/index.php?service=baseentry&action=addFromUploadedFile

uploadToken->add() returns an object which includes an id, that id is then passed on to the upload call, along with the file
then addFromUploadedFile() should get the entry, token and upload type.

This translates to something like:

# curl "-dclientTag=kalcli%3A15-08-12&uploadToken%3AobjectType=KalturaUploadToken&uploadToken%3AfileName=%2Ftmp%2Ffile&ks" "https://www.kaltura.com/api_v3/index.php?service=uploadtoken&action=add"
# curl "-dclientTag=kalcli%3A15-08-12&fileData=@somefile&uploadTokenId=&ks=" "https://www.kaltura.com/api_v3/index.php?service=uploadtoken&action=upload"
# curl "-dclientTag=kalcli%3A15-08-12&uploadTokenId=&ks=&entry%3AobjectType=KalturaBaseEntry" "https://www.kaltura.com/api_v3/index.php?service=baseentry&action=addFromUploadedFile"

I would suggest you use the Kaltura CLI client libs to experiment. It is very easy because it also gives you a nice and easy tab completion when working from the shell and you can then use the -c flag to generate curl commands out of it, for instance:

# kalcli -x -c baseentry addFromUploadedFile uploadTokenId=$TOKEN  ks=`genks -b 102` entry:objectType=KalturaBaseEntry

will output:

curl "-dclientTag=kalcli%3A15-08-12&uploadTokenId=&ks=&entry%3AobjectType=KalturaBaseEntry" "https://www.kaltura.com/api_v3/index.php?service=baseentry&action=addFromUploadedFile"

You can download it from http://cdnbakmi.kaltura.com/content/clientlibs/cli_14-05-2015.tar.gz
Also see README here:
https://github.com/kaltura/server/blob/Jupiter-10.20.0/generator/sources/cli/README.md

Which contains examples including one for Uploading files.

You have been INCREDIBLY helpful, this is exactly what I needed. Thank you for taking the time to make a meaningful response, I now have video successfully pushing to Kaltura from the media asset management system.

Glad to hear && happy to assist.