cancel
Showing results for 
Search instead for 
Did you mean: 

cl_rest_http_client GET - Communication Failure

Deon_van_Zyl
Active Participant
5,311

Hi,

I have an interesting error which I am not sure how to solve. I am calling an API with HTTP REST Service with a GET request. If I run my program as is, I get a communication failure from CL_REST_HTTP_CLIENT-IF_REST_RESOURCE~GET. If I put a debug point on my method call, the GET request works perfectly and I get a status 200 back with a response. The only difference is that I enter debug mode, nothing else changes. Without debug, I get a communication failure, with debug, I get response 200 and everything works perfectly.

I get see the the communication failure happens in CL_REST_HTTP_CLIENT-SEND_RECEIVE when it does the CALL METHOD mo_http_client->receive. When I try to debug the method, then I don't get the communication error anymore 😞

Any suggestions? I have tried to do a commit and wait before the HTTP Get and Wait up to 10 seconds but that makes no difference.

* Create REST client instance
    CREATE OBJECT lo_rest_client
      EXPORTING
        io_http_client = go_http_client.


    "/--- Do HTTP GET Request ---/"
    TRY.


        lo_rest_client->if_rest_client~get( ).


      CATCH cx_rest_client_exception INTO DATA(lo_exc).
        lv_message = lo_exc->get_text( ).


        CALL METHOD send_mail EXPORTING iv_message = lv_message.


        WRITE:/ 'HTTP Connection Error: ', lv_message.


        EXIT.


    ENDTRY.

Kind Regards
Deon

Accepted Solutions (1)

Accepted Solutions (1)

Deon_van_Zyl
Active Participant

BASIS increased the HTTPS timeout and it now it works. I am still not sure why the "WAIT UP TO sec SECONDS" worked but at least it is working now 🙂

Answers (0)