2020 Sep 09 11:16 AM
Hi Experts,
Thank you very much for taking your time to review this issue.
In my case, I want to use ABAP development to achieve access to enterprise wechat. But always received the MSG 417 and failed: NIEHOST_UNKNOWN(-2) . I don't know if there is no configuration or what needs to be done.
Please help me.Thank you very much for your reply.
Here is my code:
DATA: lo_http_client TYPE REF TO if_http_client,
gv_json_out TYPE string,
lv_url TYPE string,
lv_auth TYPE string,
lv_head TYPE string,
lv_len TYPE i,
iv_json_input TYPE string,
ev_json_output TYPE string,
l_content TYPE char1024,
l_value TYPE savwctxt-fieldcont.
DATA: l_sysubrc TYPE sysubrc,
l_error_text TYPE string.
lv_url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=xxxxx&corpsecret=xxxxx'.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_url
* proxy_host =
* proxy_service =
* 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->propertytype_logon_popup = lo_http_client->co_disabled.
CALL METHOD lo_http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.
IF sy-subrc <> 0.
ENDIF.
CALL METHOD lo_http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
IF sy-subrc <> 0.
CALL METHOD lo_http_client->get_last_error
IMPORTING
code = l_sysubrc
message = l_error_text.
WRITE:/ l_sysubrc,
/ l_error_text.
ENDIF.
CLEAR ev_json_output.
ev_json_output = lo_http_client->response->get_cdata( ).
REPLACE ALL OCCURRENCES OF REGEX '\n' IN ev_json_output WITH space.
IF ev_json_output IS INITIAL.
WRITE: / 'faild'.
ELSE.
WRITE: / ev_json_output.
ENDIF.
CALL METHOD lo_http_client->close.
Here is the output:
2020 Sep 09 11:22 AM
Hello hulianzhou
https://answers.sap.com/questions/222748/conection-error-niehostunknown-2-using-clhttpclien.html
Kind regards,2020 Sep 10 4:09 AM
Hi Mateusz,
Thank you very much. I'm trying the solution you've provided, and I'm still testing it.
2020 Sep 09 6:53 PM
You may also want to refer SAP Note 2735653 - Connections under "HTTP Connections to External Server" folder throws error- Connect to http://xxxxxx failed:NIEHOST_UNKNOWN(-2)
2020 Sep 10 4:09 AM
Hi Kartik,
Thank you very much. I'm trying the solution you've provided, and I'm still testing it.