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

Hidden Form fields in an HTTP POST

tony_raimo2
Explorer
0 Likes
1,345

Does anyone know how to pass hidden form fields into an HTTP Post? Here is an example in HTML. I need to do the same thing in ABAP:

<html>

<body>

<FORM ACTION="https://www.aesdirect.gov/weblink/weblink.cgi" METHOD="POST">

<INPUT TYPE="HIDDEN" NAME="wl_app_ident" VALUE="TEST">

<INPUT TYPE="HIDDEN" NAME="wl_nologin_url" VALUE="http://www.weblinktestapp.com/nologin.html">

<INPUT TYPE="HIDDEN" NAME="wl_nosed_url" VALUE="http://www.weblinktestapp.com/nosed.html">

<INPUT TYPE="HIDDEN" NAME="wl_success_url" VALUE="http://www.weblinktestapp.com/success.html">

<input type="submit" value="Submit">

</FORM>

</body>

</html>

Here is my code so far:

L_POST_URI = '/weblink/weblink.cgi'.

POST_HOST = 'www.aesdirect.gov'.

CALL METHOD cl_http_client=>create

EXPORTING

host = POST_HOST

service = '443'

scheme = '2'

ssl_id = 'ANONYM'

  • proxy_host = wf_proxy

  • proxy_service = wf_port

IMPORTING

client = http_client.

http_client->propertytype_logon_popup = http_client->co_disabled.

wf_user = '' .

wf_password = '' .

  • proxy server authentication

CALL METHOD http_client->authenticate

EXPORTING

proxy_authentication = 'X'

username = wf_user

password = wf_password.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = '~request_method'

value = 'POST'.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = '~request_protocol'

value = 'HTTPS/1.0'.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = 'HOST'

value = POST_HOST.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = '~request_uri'

value = L_POST_URI.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = 'Content-Type'

value = 'text/xml; charset=utf-8'.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = 'Content-Length'

value = txlen.

*CALL METHOD http_client->request->set_header_field

  • EXPORTING

  • name = 'SOAPAction'

  • value = 'https://gatewaybeta.fedex.com:443/GatewayDC'

data: lt_formfields type TIHTTPNVP.

data: ls_formfields type IHTTPNVP.

ls_formfields-name = 'wl_app_ident'.

ls_formfields-value = 'TEST'.

append ls_formfields to lt_formfields.

*ls_formfields-name = 'wl_app_name'.

*ls_formfields-value = 'TEST'.

*append ls_formfields to lt_formfields.

ls_formfields-name = 'wl_nosed_url'.

ls_formfields-value = 'http://www.weblinktestapp.com/nosed.html'.

append ls_formfields to lt_formfields.

ls_formfields-name = 'wl_success_url'.

ls_formfields-value = 'http://www.weblinktestapp.com/success.html'.

append ls_formfields to lt_formfields.

CALL METHOD http_client->request->set_form_fields

EXPORTING

FIELDS = lt_formfields.

CALL METHOD http_client->request->set_cdata

EXPORTING

data = wf_string

offset = 0

length = rlength.

CALL METHOD http_client->send

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2.

CALL METHOD http_client->receive

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2

http_processing_failed = 3.

CLEAR wf_string1 .

wf_string1 = http_client->response->get_cdata( ).

thank you,

1 ACCEPTED SOLUTION
Read only

UweFetzer_se38
Active Contributor
0 Likes
685

Hi Tony,

for an HTTP-POST it's irrelevant whether the field is hidden or not. Just pass the fields as described in your source example.

Regards, Uwe

Does anyone know how to pass hidden form fields into an HTTP Post? Here is an example in HTML. I need to do the same thing in ABAP:

<html>

<body>

<FORM ACTION="https://www.aesdirect.gov/weblink/weblink.cgi" METHOD="POST">

<INPUT TYPE="HIDDEN" NAME="wl_app_ident" VALUE="TEST">

<INPUT TYPE="HIDDEN" NAME="wl_nologin_url" VALUE="http://www.weblinktestapp.com/nologin.html">

<INPUT TYPE="HIDDEN" NAME="wl_nosed_url" VALUE="http://www.weblinktestapp.com/nosed.html">

<INPUT TYPE="HIDDEN" NAME="wl_success_url" VALUE="http://www.weblinktestapp.com/success.html">

<input type="submit" value="Submit">

</FORM>

</body>

</html>

Here is my code so far:

L_POST_URI = '/weblink/weblink.cgi'.

POST_HOST = 'www.aesdirect.gov'.

CALL METHOD cl_http_client=>create

EXPORTING

host = POST_HOST

service = '443'

scheme = '2'

ssl_id = 'ANONYM'

  • proxy_host = wf_proxy

  • proxy_service = wf_port

IMPORTING

client = http_client.

http_client->propertytype_logon_popup = http_client->co_disabled.

wf_user = '' .

wf_password = '' .

  • proxy server authentication

CALL METHOD http_client->authenticate

EXPORTING

proxy_authentication = 'X'

username = wf_user

password = wf_password.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = '~request_method'

value = 'POST'.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = '~request_protocol'

value = 'HTTPS/1.0'.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = 'HOST'

value = POST_HOST.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = '~request_uri'

value = L_POST_URI.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = 'Content-Type'

value = 'text/xml; charset=utf-8'.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = 'Content-Length'

value = txlen.

*CALL METHOD http_client->request->set_header_field

  • EXPORTING

  • name = 'SOAPAction'

  • value = 'https://gatewaybeta.fedex.com:443/GatewayDC'

data: lt_formfields type TIHTTPNVP.

data: ls_formfields type IHTTPNVP.

ls_formfields-name = 'wl_app_ident'.

ls_formfields-value = 'TEST'.

append ls_formfields to lt_formfields.

*ls_formfields-name = 'wl_app_name'.

*ls_formfields-value = 'TEST'.

*append ls_formfields to lt_formfields.

ls_formfields-name = 'wl_nosed_url'.

ls_formfields-value = 'http://www.weblinktestapp.com/nosed.html'.

append ls_formfields to lt_formfields.

ls_formfields-name = 'wl_success_url'.

ls_formfields-value = 'http://www.weblinktestapp.com/success.html'.

append ls_formfields to lt_formfields.

CALL METHOD http_client->request->set_form_fields

EXPORTING

FIELDS = lt_formfields.

CALL METHOD http_client->request->set_cdata

EXPORTING

data = wf_string

offset = 0

length = rlength.

CALL METHOD http_client->send

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2.

CALL METHOD http_client->receive

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2

http_processing_failed = 3.

CLEAR wf_string1 .

wf_string1 = http_client->response->get_cdata( ).

thank you,

1 REPLY 1
Read only

UweFetzer_se38
Active Contributor
0 Likes
686

Hi Tony,

for an HTTP-POST it's irrelevant whether the field is hidden or not. Just pass the fields as described in your source example.

Regards, Uwe