Skip to Content

Getting bad request 400 error while making rfc connection test to servucebow using web listener

Hello Experts,

I am totally new to sap , I am currently integrating solman 7.2 to servicenow using rfc (http to external server) using a listener on a specific port.

Through the listener us reachable , I am getting 400 bad request error when I configure the API in rfc (host name - Listener host, port and API path prefix ) .

The same rest API works from other test interfaces like ..postman and Powershell ise however it's failing here.

I have not been able to find the root cause for this.

Could you please guide me how to investigate further and what could be the possibilly be the reason for this issue.

Regards,

Sandeep

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Oct 21, 2019 at 07:19 AM

    Hi Sandeep Pati,

    If you want to consume a API, you can follow the below approach too. This approach directly consumes the URL instead of the RFC. Check if this works for your scenario.

    DATA:
       lo_http_client TYPE REF TO if_http_client,
       lo_rest_client TYPE REF TO cl_rest_http_client,
       lo_exp         TYPE REF TO zcx_rest_misc_exp,
       lo_response    TYPE REF TO if_rest_entity,
       lo_request     TYPE REF TO if_rest_entity.
    
    DATA:
      lv_url   TYPE string,
      lv_data  TYPE string,
      lv_errcd TYPE i,
      lv_response  TYPE string.
    
    lv_url  = '<your url here>'.
    lv_data = '<JSON data>'.
    
    "Create request
    cl_http_client=>create_by_url(
      EXPORTING
        url                = lv_url
      IMPORTING
        client             = lo_http_client   " HTTP Client Abstraction
      EXCEPTIONS
        argument_not_found = 1
        plugin_not_active  = 2
        internal_error     = 3
        OTHERS             = 4
    ).
    
    "Set protocol
    lo_http_client->request->set_version( if_http_request=>co_protocol_version_1_0 ).
    
    "Create rest request
    CREATE OBJECT lo_rest_client
      EXPORTING
        io_http_client = lo_http_client.
    
    "Request request
    lo_request = lo_rest_client->if_rest_client~create_request_entity( ).
    lo_request->set_content_type( iv_media_type = if_rest_media_type=>gc_appl_json ).
    lo_request->set_string_data( lv_data ).
    
    lo_rest_client->if_rest_resource~post( io_entity = lo_request ).
    lo_response = lo_rest_client->if_rest_client~get_response_entity( ).
    lv_errcd = lo_response->get_header_field( iv_name = `~status_code` ).
    lv_response = lo_response->get_string_data( ).
    

    Thanks,

    Gourab

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.