Update api.php

Remove else conditions because there's really no reason as the if logic will throw an Exception.