2016 Mar 01 10:35 AM
hi,
i am trying to send request to public available url as shown below
DATA:http_client TYPE REF TO if_http_client,
surl TYPE string VALUE 'http://eenadu.net/',
cl_http_client=>create_by_url( EXPORTING
url = surl
IMPORTING client = http_client ).
CALL METHOD http_client->send
EXPORTING
timeout = timeout
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
ENDIF.
after executing send method sy-subrc is zero.
But getting http_communication_Failure for receive method.
CALL METHOD http_client->receive
exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
* HTTP_CLIENT->RESPONSE->GET_STATUS( IMPORTING CODE = RLENGTH ).
data = http_client->response->get_cdata( ).
to send request to a publicly available url do we need to configure in system or how to send data to https hosted url from abap server?
could you please share details.
hi,
i am trying to send request to public available url as shown below
DATA:http_client TYPE REF TO if_http_client,
surl TYPE string VALUE 'http://eenadu.net/',
cl_http_client=>create_by_url( EXPORTING
url = surl
IMPORTING client = http_client ).
CALL METHOD http_client->send
EXPORTING
timeout = timeout
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
ENDIF.
after executing send method sy-subrc is zero.
But getting http_communication_Failure for receive method.
CALL METHOD http_client->receive
exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
* HTTP_CLIENT->RESPONSE->GET_STATUS( IMPORTING CODE = RLENGTH ).
data = http_client->response->get_cdata( ).
to send request to a publicly available url do we need to configure in system or how to send data to https hosted url from abap server?
could you please share details.
2016 Mar 01 11:51 AM
Hi,
we are using a HTTP request to get the current metal prices.
For that intranet application first we call method CREATE_BY_DESTINATION. That's where you are using CREATE_BY_URL. That seems to be okay.
Before we send our request with method SEND, we are filling some request header fields with method REQUEST->SET_HEADER_FIELD(). In our sample this are some parameters with name '~request_method' and value 'GET', name '~server_protocol' with value 'HTTP/1.1' and name '~accept' with value 'text/plain'.
I think you'll need also some header fields for the http request.
Additionally it's also a good idea to examine some response header fields with method RESPONSE->GET_HEADER_FIELD() after receiving a result. Header fields '~status_code', '~status_reason' and '~content_type' may be useful for example before you call RESPONSE->GET_CDATA().
Regards,
Klaus