Migrate code to rest client