Application Development 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: 

Call an URL with ABAP program (Method POST)

Former Member
0 Kudos

Hi everyone,

  I need to call an URL for example "www.google.com?q=hello" with ABAP using POST method.

  Like the FM "Call_Browser", but my variable q=hello need to be passed with POST method.

Any idea ?

Thanks.

10 REPLIES 10

Former Member
0 Kudos

0 Kudos

Thanks Felipe. But it's doesn't help. I need to do the same thing of MF CALL_BROWSER, but my data need to be passed by POST method.

Regards.

buddhika_krishantha
Active Participant
0 Kudos

This may be useful.

0 Kudos

This won't work, it is used to construct webdynpro URL with GET parameters.

Former Member
0 Kudos

here is one example I use from abap to call a web browser ITS solution with a project number, I guess you can adapt the it for your purpose?

      check <data>-pspid is not initial.
      concatenate gv_pfs_link
                  'zpfs2?~okcode=PROJ_SEL&zpspid=<###>&sel_action=X'
      into lv_url.

      replace '<###>' with <data>-pspid into lv_url.
      condense lv_url no-gaps.

      cl_gui_frontend_services=>execute(
        exporting document = lv_url ).

0 Kudos

Hey Steve,

Your solution is to construct URL with GET parameters => www.test.com?parm1=val1&param2=val2

I need to CALL an URL with POST parameters, so my parameters wont be visible in the browser. => in the browser i want to only see the www.test.com without the parameters ?parm1=val1&param2=val2.

Former Member
0 Kudos

Hi Medhi,

Did you find the solution for this??? i´m trying to do the same thing.!

HELP..!

0 Kudos

Hello, I was looking for an answer and finally I got it.  please see this link

https://wiki.scn.sap.com/wiki/x/GQx2Gg

I hope this helps.

Regards

Carlos Andres Gonzalez

0 Kudos

Hi everyone,

I know this is a very old post but I need to do exactly the same (to open an url and send parameters by post method) and I don't find any other useful answer in any other post... The url mentioned in the last answer is not working anymore, so is it possible to get an updated url or to let me know how to access this information?

Or somebody found any other way to do it?

Many thanks.

Regards,

Xavi.

0 Kudos

Hi Xavi.

Attaching a sample coding below to open an url and send parameters by post method check if it is helpful.

PARAMETERS: p_url(240) TYPE c LOWER CASE DEFAULT ' https://community.sap.com/&user=(2)&password=(3)'." only for info purpose

*In STRUST T-Code upload the certificate
*and configure in SM59 and use
*that SSL Id ( 'SSL_TEST')here , For some URLs it is not needed
PARAMETERS: p_ssl TYPE ssfapplssl LOWER CASE DEFAULT 'SSL_TEST'. " SSL ID
PARAMETERS: p_usrath AS CHECKBOX DEFAULT ''." User Authentification
PARAMETERS: p_userx(30) TYPE c LOWER CASE DEFAULT ''." HTTP User
PARAMETERS: p_pwd(30) TYPE c LOWER CASE DEFAULT ''.
PARAMETERS: p_prxy TYPE char1 AS CHECKBOX DEFAULT ''."Proxy-Authentication
PARAMETERS: p_sprt TYPE char1 RADIOBUTTON GROUP g1, " Server-Protocol
p_rprt TYPE char1 RADIOBUTTON GROUP g1 DEFAULT 'X'. "Request-Protocol


DATA: client TYPE REF TO if_http_client,
lv_subrc TYPE sy-subrc,
e_msg TYPE string.

DATA : lv_user TYPE string,
lv_pwd TYPE string,
lv_ssl TYPE ssfapplssl,
lv_hdr TYPE string,
lv_url TYPE string.

CLEAR : lv_ssl, lv_url, lv_user, lv_pwd.

" As the method below accepts only string

lv_ssl = p_ssl.
lv_user = p_userx.
lv_pwd = p_pwd.
lv_url = p_url.

CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_url
* proxy_host = p_host
* proxy_service = p_srv
ssl_id = lv_ssl
IMPORTING
client = client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.


IF sy-subrc <> 0.
CALL METHOD client->get_last_error
IMPORTING
code = lv_subrc
message = e_msg.
MESSAGE e_msg TYPE 'E'.
ENDIF.

IF p_usrath = 'X'.
* Aunthenticate HTTP CLIENT Usually when the user and password is not provided in the URL as the default value in the declaration
CALL METHOD client->authenticate
EXPORTING
proxy_authentication = p_prxy
username = lv_user
password = lv_pwd
language = sy-langu.
ENDIF.


* Information to the Header
CALL METHOD client->request->set_header_field
EXPORTING
name = '~request_method'
value = 'POST'.

IF p_sprt EQ abap_true.
lv_hdr = '~server_protocol'.
ELSE.
lv_hdr = '~request_protocol'.
ENDIF.
CALL METHOD client->request->set_header_field
EXPORTING
name = lv_hdr
value = 'HTTP/1.1'.

CALL METHOD client->request->set_header_field
EXPORTING
name = 'Content-Type'
value = 'text/xml'.

Regards,

Pallavi Andole