Fixes #4856 Make sure setAPIUrl, when called, is executed before any other request is sent.