Fixed bug with rest api urls
A bunch of bugfixes for ApiHandler