API: return 400 and better message for missing entity

Fix issue #380
We should use the invalidAPICall() method that sends a 400 and returns a formatted error message:
```php
$request->error = 'Entity not available';
$json = $request->invalidAPICall();
```