raise an exception when api call doesn't return status OK.