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

Http post with parameters

0 Likes
7,357

Hi All,

We want to send an HTTP post with parameters, and we are not sure how to do that. We tried to do that like the code below,but we get the parameters in the body and not in the header ...

DATA lo_client TYPE REF TO if_http_client.

DATA lv_status_code TYPE i.

DATA lv_reason TYPE string.

CALL METHOD cl_http_client=>create_by_destination

EXPORTING

destination = 'ZRFC_TEST'

IMPORTING

client = lo_client.

lo_client->request->set_method( if_http_request=>co_request_method_post ).

cl_http_utility=>set_request_uri( request = lo_client->request

uri = '?param1=value1' ).

lo_client->send( ).

lo_client->receive( ).

lo_client->response->get_status( IMPORTING code = lv_status_code

reason = lv_reason ).

Thanks a lot,

Tuvia.

1 ACCEPTED SOLUTION
Read only

mvoros
Active Contributor
0 Likes
3,108

Hi,

I am not sure if I understand your issue but as you know you can set up GET parameters just by modifying URL and you should be able to modify post parameters by calling methods SET_FORM_FIELD and SET_FORM_FIELDS of request object. Similar as you set request method.

Cheers

3 REPLIES 3
Read only

mvoros
Active Contributor
0 Likes
3,109

Hi,

I am not sure if I understand your issue but as you know you can set up GET parameters just by modifying URL and you should be able to modify post parameters by calling methods SET_FORM_FIELD and SET_FORM_FIELDS of request object. Similar as you set request method.

Cheers

Read only

0 Likes
3,108

Hi Matrtin,

Thanks for your helpful answer. Your solution helps us to put the parameters in the body, but we need a way to put the

parameters on the query, do you know of a way to do that?

Thanks,

Tuvia.

Read only

0 Likes
3,108

Hi,

what do you mean by "parameters on the query". In any http request you can have two types of variables: POST or GET. The post variables are transferred in http header and you can add them using methods from my previous post. GET variables are transferred in URL. HTTP client has a method APPEND_FIELD_URL which can be used to add variable into URL string.

Cheers