When using SOAP, I would like to list the field names and values for a schema, or all of them for an asset. So, I figured I would use the GetMetadataFieldValues method. In the manuals, it says the asset ID is mandatory, but does not say the FieldNames are.
If I do not include any field names in the request, I get back an empty response with no metadata or field names. But, if I do specify some field names, I correctly get the metadata back.
My question is, it seems that FieldNames ARE mandatory, as it returns nothing if this is not specified. If they ARE mandatory, how does one ever retrieve metadata field names in SOAP without previously knowing the names of those fields? I could retrieve the values by field ID, but I would like to also get the field name since I do not know them.
It looks like there is a bug in the following function:
function GetMetadataFieldValues($request) { $request_info = (Array) $request; $assetid = array_get_index($request_info, 'AssetID', ''); $field_names = array_get_index($request_info, 'FieldNames', ''); if (!empty($assetid)) { $mm = $GLOBALS['SQ_SYSTEM']->getMetadataManager(); $schemas = $mm->getSchemas($assetid); if (empty($schemas)) { throw new SoapFault('Server', 'There is no metadata schema applied on this asset'); }//end if if (!is_array($field_names)) { $field_names = Array ($field_names); }//end if $field_values = $mm->getMetadataFieldValues($assetid, $field_names); $field_values_final = Array(); $i = 0; foreach ($field_values as $field_name => $field_value) { $field_values_final[$i]['FieldName'] = $field_name; $field_values_final[$i]['FieldValue'] = $field_value; $i++; }//end foreach return Array ( 'GetMetadataFieldValuesResult' => $field_values_final, ); } else { throw new SoapFault('Server', 'Asset ID Is Not Valid. Please Provide A Valid Asset ID'); }//end else }//end GetMetadataFieldValues()
It seems like if you don't want to set a FieldNames that it doesn't matter, because it gets set as an array no matter what. Still investigating...