by Matthias Grähn.
Hi,
I have a webservice which should return a single record with different values or an empty value
public static function find_me_returns()
{
$entry = new external_single_structure(
array(
'id' => new external_value(PARAM_INT, 'Id of the user'),
'idnumber' => new external_value(PARAM_TEXT, 'External id number of the user'),
'suspended' => new external_value(PARAM_INT, 'Suspended state of the user'),
), 'find me values', VALUE_OPTIONAL);
return entry;
}
The function itself declares an empty return value:
$return_value = array();
So if nothing is found there should be an empty array.
But instead i get:
"debuginfo": "Error in response - Missing following required key in a single structure: id"
It seems that the VALUE_OPTIONAL for this single_structure record is found.
How can I fix this?