11-22-2012 2:24 PM
I need to call an HTTP url from abap program. The url display a pdf document from external repository. I don't know how send user and password; I need to insert this parameter in HEADER.
Does anybody help me?
Thanks.
Bye
Q
11-22-2012 3:16 PM
You can try CL_HTTP_CLIENT class for this. Not sure your exact requirement, but you could give a try. There is an instance method IF_HTTP_CLIENT~AUTHENTICATE to send the user id password. If your URL supports, it might work.
Rest of some sample coding. May be helpful for you.
DATA : lr_client TYPE REF TO if_http_client.
CALL METHOD cl_http_client=>CREATE_BY_URL
EXPORTING
url = lv_url
* SERVICE = '80'
* SCHEME = '1'
* PROXY_HOST = WF_PROXY
* PROXY_SERVICE = WF_PORT
IMPORTING
client = lr_client.
CALL METHOD lr_client->request->set_header_field
EXPORTING
name = '~request_method'
value = 'POST'.
CALL METHOD lr_client->request->set_header_field
EXPORTING
name = '~server_protocol'
value = 'HTTP/1.1'.
CALL METHOD lr_client->request->set_header_field
EXPORTING
name = '~url'
value = lv_url.
CALL METHOD lr_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.