Digital Media Suite API Forums

« Back to Digital Signs API Forum

upload an asset dynamically with PHP or ASP etc.

Combination View Flat View Tree View
Threads [ Previous | Next ]
Does anyone know how I can upload an asset dynamically?
E.g. using php to build the xml string and then post the request to the DMM.

I've tried the following but I always get an error message





<?php
$xml = '<n1:asset xmlns:n1="http://www.cisco.com/dms/xml/ns/dsm/contentManagement">
<title>Testing</title>
<fileName>http://192.168.11.30:8080/temp/dr_1.html</fileName>
<description>dr_1description</description>
<fileType>HTML</fileType>
<estimatedDuration>
<Hours>0</Hours>
<Minutes>0</Minutes>
<Seconds>10</Seconds>
</estimatedDuration>
<categoryIdList><id>5</id></categoryIdList>
<assetOwner>admin</assetOwner>
<storageType>url</storageType>
<downloadurl>true</downloadurl>
</n1:asset>';

$url = "http://dmst.xxxx.com:8080/xTAS-core/services/content/assets/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_USERPWD, "admin:Cisco123");
$result = curl_exec($ch);
curl_close($ch);
echo $result;
?>






Error message...




HTTP/1.1
415 Unsupported Media Type Server: Apache-Coyote/1.1 Content-Type: text/xml;charset=UTF-8 Content-Length: 0 Date: Fri, 24 Dec 2010 05:23:22 GMT






Anyone got any clue what's wrong with the script?

Try changing your content type to "multipart/form-data"
 
-Hashir

I've just tried changing content type to "multipart/form-data" and it returned the following error...
 
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Content-Type: application/xml;charset=UTF-8
Content-Length: 466
Date: Mon, 17 Jan 2011 07:54:18 GMT
Connection: close
failure<code>Internal Server Error</code>Could
not parse multipart servlet request; nested exception is
org.apache.commons.fileupload.FileUploadException: the request was
rejected because no multipart boundary was found