Hi Dears,
I am getting 443:Failed: NIECONN_REFUSED(-10) when I try to call external API from ABAP with post operation. Same thing working fine from Postman tool if i post.
data:
lv_error_msg type string,
lv_url type string,
lt_xml_table type table of smum_xmltb,
ls_xml_table type smum_xmltb,
lt_return type table of bapiret2,
lv_xml_input type xstring.
data:
lv_body_string type string,
lv_body_string1 type string,
lv_body_string2 type string,
lv_rlength type i,
lv_txlen type string.
data:
lv_token type string,
lv_tarih type sy-datum,
lv_http_client type ref to if_http_client,
lv_xml_document type ref to cl_xml_document.
lv_url = 'https://xxxxxxxxxxxxxxxxxxxxx/api/v1/export/profiles'.
concatenate
'{'
'"benutzernummer":["000000005561"]}' into lv_body_string.
lv_rlength = strlen( lv_body_string ).
move: lv_rlength to lv_txlen.
call method cl_http_client=>create_by_url
exporting
url = lv_url
importing
client = lv_http_client
exceptions
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
others = 4.
if sy-subrc <> 0.
return.
endif.
lv_http_client->propertytype_logon_popup =
lv_http_client->co_disabled.
lv_http_client->request->set_content_type( 'application/json' ).
call method lv_http_client->request->set_header_field
exporting
name = '~request_method'
value = 'POST'.
call method lv_http_client->request->set_header_field
exporting
name = 'Content-Length'
value = lv_txlen.
call method lv_http_client->request->set_header_field
exporting
name = 'Content-Type'
value = 'application/json'.
call method lv_http_client->request->set_header_field
exporting
name = 'client_id'
value = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'.
call method lv_http_client->request->set_header_field
exporting
name = 'client_secret'
value = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'.
call method lv_http_client->request->set_cdata
exporting
data = lv_body_string
offset = 0
length = lv_rlength.
call method lv_http_client->send
exceptions
http_communication_failure = 1
http_invalid_state = 2.
call method lv_http_client->receive
exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
"Here sy-subrc returns 1
lv_http_client->get_last_error( importing message = lv_error_msg ).
if lv_error_msg is not initial."here mesaage says icm_hhtp_connection_broken
lv_http_client->close( ).
return.
endif.
data: lv_status type i.
lv_http_client->response->get_status( importing code = lv_status ).
if lv_status ne 201.
lv_http_client->close( ).
return.
endif.
*rv_return_struct = lv_http_client->response->get_cdata( ).
lv_http_client->close( ).
getting error: Connect to xxxxxxxxxxxxxxxxxxxxx:443 failed: NIECONN_REFUSED(-10)