Skip to Content
May 14, 2012 at 12:01 PM

How to change the Host during CL_HTTP_CLIENT session


I am trying to communicate with a Cloud service ( ) using class CL_HTTP_CLIENT.

My problem is that I need to change the host name during the communication. (A similar problem can be found CL_HTTP_CLIENT authentication and data hosts are not same but was not solved in ABAP there).

The REST interface needs to be addressed this way:

  1. GET you get a server name and a session id as answer
  2. POST now you use host (or for authenticating the session that started in step 1

In ABAP I use cl_http_client=>create_by_url for step 1 and do the GET command. Now I need to change the host for the POST command in step 2.

I tried to use

call method ro_api->o_client->request->set_header_field    exporting      name  = '~host'      value = ''.

but this does not seem to work.

Could this work in general? In Python you would change the socket of the http client for doing this. But is anything similar possible in ABAP?