Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Call HTTP url from abap

Quark_G
Explorer
0 Likes
2,169

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

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

1 REPLY 1
Read only

Former Member
0 Likes
943

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.