Вопрос

I'm sending the following json: {"name":"New event"}

to a PATCH handler: function patch($id, $request_data = NULL)

but am getting the following warning: Warning: strlen() expects parameter 1 to be string, array given in /public_html/vendor/Luracast/Restler/Data/Validator.php on line 115

The source at that line is:

switch ($info->type) {
    ...
    case 'string' :
       $r = strlen($input);

So I added some code to the first line of Validator.validate() see what it thinks the variables are:

print("$input: $info->type\n");

and I get this:

1: int
Array: string

So it thinks the array is a string. It is still able to continue and process the request, but it returns this warning as the response instead of something valid I can process.

Any ideas what I'm doing wrong?

Это было полезно?

Решение

Latest version (Restler 3 RC4) in v3 branch fixes this issue

Другие советы

I had this problem too, but that's because I gave param wrong type.

For example

@param string $request_data

change type

 string to mixed 

the problem will be solved.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top