changed error handling in rest api call command to confirm with python best practice