SetAssetMetadata using js api request


(autjoe) #1

Hi there,

I am trying to set the asset metadata as following by using JS api via soap server.

The script can run through successfully without error, however the asset metadata was not changed.

Tried to add RegenerateMetadataAsset, still not luck. Am I missing anything?

Thanks.

 

<script type="text/javascript" src="http://SYSTEM_ROOT_URL/__data/asset_types/soap_api/web_services_caller.js"></script> 

<script type="text/javascript"> var current_system_root = 'SYSTEM_ROOT_URL';//(e.g http://yourserver.com);
include_service_lib('asset', current_system_root);
include_service_lib('metadata', current_system_root);
</script>
<script type="text/javascript">
function TosetAssetMetadata(assetid, fieldid, newvalue)
{
var location = 'http://SYSTEM_ROOT_URL/_web_services/soap-server';
var wsdl = 'http://SYSTEM_ROOT_URL/_web_services/soap-server?WSDL';
var soapBody = SetAssetMetadata(assetid, fieldid, newvalue);
var soapRequest = constructSOAPRequest(soapBody, location);
send(wsdl, soapRequest, 'getSetAssetMetadataResponse');
}//end SetAssetMetadata ()
function getSetAssetMetadataResponse(response)
{
alert('successfully');
}//end
</script>
 


(Nic Hubbard) #2

This isn't actually using the JS API, but rather the SOAP Server (which you did say). You should just use the JS API instead:

 

http://manuals.matrix.squizsuite.net/web-services/chapters/javascript-api#setMetadata

js_api.setMetadata({
   "asset_id":100,
   "field_id":900,
   "field_val":"metadata",
   "dataCallback":customDataCallbackFunc
}) 

(autjoe) #3

Thanks Nic. Js API works.