Changes to use apiUrl for REST requests

Not ready for checking in yet. I'm still testing, but should be reviewable.