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: 

Failed: NIECONN_REFUSED(-10) when calling external API from ABAP..working same from Postman

ganesh1993
Explorer
0 Kudos

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)

4 REPLIES 4

turkaj
Active Participant
0 Kudos

Hi Ganesh,

have you imported the certificate to your URL "'https://xxxxxxxxxxxxxxxxxxxxx/api/v1/export/profiles'"?

The message can also have other causes. Have you also checked the SAP system profile parameters if the following values are set in the transaction RZ10 or RZ11:

  • ssl/client_ciphersuites = 150:PFS:HIGH::EC_P256:EC_HIGH
  • ssl/ciphersuites = 135:PFS:HIGH::EC_P256:EC_HIGH
  • icm/HTTPS/client_sni_enabled = TRUE

If you follow these points it should work.

Regards
Jim

0 Kudos

Hi Shkelqim,

Thank you so much for your quick response.

Could you guide me with how to get certificate and import the same and how to check system profile parameters if possible please this is first time In-dealing with these things.

Thank you so much!!

Sandra_Rossi
Active Contributor
0 Kudos

You are using https. Look at all the question and answers already posted in the forum (STRUST).

NB: Postman/Web browser requests accessing https is not same logic as ABAP server (ABAP server needs registering).

meenakshi-btp
Explorer
0 Kudos

Hello,

Were you able to resolve this? I am facing the same issue.

We have the certificates imported in STRUST in S4 system (2022SP02), yet facing the issue.