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: 

if_http_client response code 403

former_member529557
Discoverer
953

Hi Experts,

We are using interface if_http_client to check if page "http://www.sap.com/benchmark" is working.

To create an instance we use cl_http_client=>create_by_url ().

Then call lo_http_client->send()

and lo_http_client->receive()

and with lo_http_client->response->get_status() the response code is 403 Forbidden.

The URL is working fine when testing it in the browser.

  cl_http_client=>create_by_url(
      EXPORTING
        url                =  iv_url_str
      IMPORTING
        client             =  lo_http_client
      EXCEPTIONS
        argument_not_found = 1
        plugin_not_active  = 2
        internal_error     = 3
        OTHERS             = 4 ).
    IF sy-subrc <> 0.
      lo_http_client->get_last_error( IMPORTING message = lv_error_message ).
RETURN. ENDIF.

lo_http_client->send( EXPORTING timeout = 60 EXCEPTIONS http_communication_failure = 1 http_invalid_state = 2 http_processing_failed = 3 http_invalid_timeout = 4 OTHERS = 5 ). IF sy-subrc <> 0. lo_http_client->get_last_error( IMPORTING message = lv_error_message ).
RETURN. ENDIF.
lo_http_client->receive( EXCEPTIONS http_communication_failure = 1 http_invalid_state = 2 http_processing_failed = 3 OTHERS = 4 ). IF sy-subrc <> 0. lo_http_client->get_last_error( IMPORTING message = lv_error_message ).
RETURN. ENDIF.
lo_http_client->response->get_status( IMPORTING code = lv_http_response_code reason = lv_reason_str ).
IF lv_http_response_code >= 400. lo_http_client->get_last_error( IMPORTING message = lv_error_message ).
RETURN. ENDIF.
4 REPLIES 4

Sandra_Rossi
Active Contributor
0 Kudos
834

You probably missed STRUST. Search the forum.

Sandra_Rossi
Active Contributor
0 Kudos
834

HTTP?

Use HTTPS.

former_member529557
Discoverer
0 Kudos
834

It is the same issue with URL https://www.sap.com/about/benchmark.html. (And yes we will change this. :-))

Sandra_Rossi
Active Contributor
0 Kudos
834

You probably missed STRUST. Search the forum.