on 12-02-2016 2:21 PM
HI EXPERTS,
I NEED TO CONSUME REST SERVICE URL AND FETCH THE OUTPUT IN JSON FORMAT,BUT AM GEETING 404 ERROR
REPORT ZTETS_JSON.
DATA: lo_http_client TYPE REF TO if_http_client.
data : lv_url TYPE string,
lv_payload TYPE string value '[{ebeln: "3000000006", ebelp: "00001", matnr: "", bukrs: "3000", matkl: "014"}]',
lv_payload_x TYPE xstring,
lv_auth TYPE string,
lv_response TYPE string.
DATA : lv_http_code TYPE i,
lv_http_reason TYPE string.
START-OF-SELECTION.
PARAMETERS: p_fname TYPE char30 OBLIGATORY,
p_lname TYPE char30 OBLIGATORY.
**
*"concatenate the input parameters value with the url
CONCATENATE 'http://192.168.2.66:8080/sap/bc/zsubmitalv?'
'FNAME=' p_fname '&'
'LNAME=' p_lname INTO lv_url.
cl_http_client=>create_by_url(
EXPORTING
url = lv_url
IMPORTING
client = lo_http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4 ).
IF sy-subrc <> 0.
RETURN.
ENDIF.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = lv_payload
IMPORTING
buffer = lv_payload_x.
*
CALL METHOD lo_http_client->request->set_header_field
EXPORTING
name = 'sapuser'
value = 'India@123'.
lo_http_client->request->set_method( 'GET' ).
lo_http_client->request->set_content_type( 'application/json' ).
lo_http_client->request->set_data( lv_payload_x ).
lo_http_client->propertytype_logon_popup = if_http_client=>co_disabled.
* Sending the request
lo_http_client->send(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2 ).
IF SY-SUBRC EQ 0.
* Receiving the response
lo_http_client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3 ).
ENDIF.
IF SY-SUBRC EQ 0.
*get the status of the response
CALL METHOD lo_http_client->response->get_status
IMPORTING
code = lv_http_code
reason = lv_http_reason.
ENDIF.
lv_response = lo_http_client->response->get_cdata( ).
WRITE : lv_response .
HERE WHILE RECEIVING RESPONSE AM GEETING ERROR(Connect to proxy:8080 failed: NIEHOST_UNKNOWN(-2) ).....
PLEASE TELL ME HOW TO RESOLVE THIS ISSUE........................
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.