Quantcast
Channel: Web services
Viewing all articles
Browse latest Browse all 2361

invalid_response_exception for Optional single structure

$
0
0
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?




Viewing all articles
Browse latest Browse all 2361

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>