trying to create a custom rest client for es,,,do not look at the code is really ugly