Fix API to return errors when wrong entity.