When I have a field set to json or array and post something to that collection, it will execute the post but add the following warning after the json response:
{
... the expected json object of the collection
}
<br/ > ↵ < b > Warning </b>: strlen() expects parameter 1 to be string, array given in <b>/api/ src/core/Directus/Services/AbstractService.php </b> on line <b>500</b> <br / > ↵
I get the same error when using the app to update in some collections. The error reads:
API returned invalid JSON
when i inspect it it's because of the same error as above: first the JSON object, then the error message.
Just correct json response
json response plus added error message
Latest build branch of the API
Probably not very elegant but a quick fix is to add:
$testvalue = '';
if (is_array($value) || is_object($value)) {
$testvalue = json_encode($value);
} else {
$testvalue = $value;
}
to src/core/Directus/Services/AbstractService.php in line 500 (beginning of the else clause)
and then change strlen($value) to strlen($testvalue)
Fixed in #1024
@bjgajjar Thanks for fixing - when will this be in the build branch?
Hey @Kinzi
If everything will work as per the plan; then we will make it live at today EOD.
Most helpful comment
Hey @Kinzi
If everything will work as per the plan; then we will make it live at today EOD.