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: 

Issue in Consuming Rest/JSON Service from Netweaver gateway system

knitinkumarsethy
Explorer
0 Kudos

Hello Experts,

We are trying to consume the Rest/JSON web service from NetWeaver Gateway System.

But we are getting HTTP Communication failure error.

URL: 'http://sgpvmc0031.apac.bosch.com/ActivityManager2/rest/v1/query/employees/amh1sgp/workItems/pending'

The Host system of Serve is a Non-SAP System.

In web browser, it ask for user id and password, by passing them, it provide the response.

Please find my code details.

DATA: lo_http_client TYPE REF TO if_http_client,
         lv_service TYPE string,
         lv_result TYPE string,
         lo_ixml TYPE REF TO if_ixml,
         lo_streamfactory TYPE REF TO if_ixml_stream_factory,
         lo_istream TYPE REF TO if_ixml_istream,
         lo_document TYPE REF TO if_ixml_document,
         lo_parser TYPE REF TO if_ixml_parser,
         lo_weather_element TYPE REF TO if_ixml_element,
         lo_weather_nodes TYPE REF TO if_ixml_node_list,
         lo_curr_node TYPE REF TO if_ixml_node,
         lv_value TYPE string,
         lv_node_length TYPE i,
         lv_node_index TYPE i,
*        ls_weather TYPE zweather,
         lv_node_name TYPE string,
         lv_bin            type xstring,
         lv_node_value TYPE string,
         lo_conv           type ref to cl_abap_conv_in_ce,
         lv_response       type string,
         l_client type string.

DATA: result_tab TYPE TABLE OF string,
          w_result TYPE string .


   lv_service = 'http://sgpvmc0031.apac.bosch.com/ActivityManager2/rest/v1/query/employees/amh1sgp/workItems/pending'.
*  lv_service = 'https://rb-wam-q.bosch.com/ActivityManager2/rest/v1/query/employees/amh1sgp/workItems/pending'.
*BREAK-POINT.

CALL METHOD CL_HTTP_CLIENT=>CREATE
   EXPORTING
     HOST               = 'sgpvmc0031.apac.bosch.com'
     SERVICE            = '80'
*    PROXY_HOST         =
*    PROXY_SERVICE      =
*     SCHEME             = SCHEMETYPE_HTTP
*    SSL_ID             =
*    SAP_USERNAME       =
*    SAP_CLIENT         =
   IMPORTING
     CLIENT             = lo_http_client
   EXCEPTIONS
     ARGUMENT_NOT_FOUND = 1
     PLUGIN_NOT_ACTIVE  = 2
     INTERNAL_ERROR     = 3
     others             = 4
         .
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

    lo_http_client->request->set_method( if_http_request=>co_request_method_get ).

    lo_http_client->authenticate( username = 'portal' password = 'portal' ).

    cl_http_utility=>set_request_uri(
        request = lo_http_client->request
        uri = '/ActivityManager2/rest/v1/query/employees/amh1sgp/workItems/pending'
    ).

    call method lo_http_client->request->set_header_field
       EXPORTING
         name = 'content-type'
         value = 'text/plain'.

    call method lo_http_client->send( ).
    call method lo_http_client->receive( ).

Kindly help us to understand where to check.

Regards,

Nitin

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try to test the url in the standard report RSHTTP20.

Regards,

Felipe

1 REPLY 1

Former Member
0 Kudos

Hi,

Try to test the url in the standard report RSHTTP20.

Regards,

Felipe