Changes to API controller to handle 401 and 404