JSON expected, but getting error "view missing"

I usually return this:

//Return the status code
$this->response->statusCode(201);
//then:
return json_encode(value);