fixed bug in the api_request_handler where it would generate an internal server error