web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

API in AX 2012: Could not create SSL/TLS secure channel

(1) ShareShare
ReportReport
Posted on by 7

I have a problem in AX 2012 when I call API by Https URL give me this error

(The request was aborted: Could not create SSL/TLS secure channel)

but when I test code in Dynamic 365 It Work

I've tried this:

I used this: System.Net.ServicePointManager::set_Expect100Continue(true);

System.Net.ServicePointManager::set_SecurityProtocol(System.Net.SecurityProtocolType::Tls12);

This My code:

str destinationUrl,requestJson, responseJson;System.Net.HttpWebRequest  request;System.Net.HttpWebResponse  response = new System.Net.HttpWebResponse();    CLRObject      clrObj;System.Byte[]         bytes;System.Text.Encoding     utf8;System.IO.Stream       requestStream, responseStream;System.IO.StreamReader    streamReader;System.Exception        ex;System.Net.WebHeaderCollection httpHeader;System.Net.ServicePoint    servicePt;System.Net.ServicePointManager ServicePointManager;str           byteStr;System.Byte[]      byteArray;System.IO.Stream     stream;System.IO.Stream     dataStream;int secProtocol;boolean ssl3,tls,tls11,tls12,tls13;destinationUrl = 'https://...';requestJson  = @'MyJsonData';try{  new InteropPermission(InteropKind::ClrInterop).assert();  httpHeader = new System.Net.WebHeaderCollection();  clrObj = System.Net.WebRequest::Create(destinationUrl);     request = clrObj;  utf8 = System.Text.Encoding::get_UTF8();  bytes = utf8.GetBytes(requestJson);   request.set_Method(/POST/);  httpHeader.Add(/Client-Id/,/5.../);  httpHeader.Add(/Secret-Key/,/.../);  httpHeader.Add(/Cookie/, /.../);  request.set_Headers(httpHeader);  request.set_ContentType('application/json');  request.set_ContentLength(bytes.get_Length());   //ServicePointManager.Expect100Continue = true;    System.Net.ServicePointManager::set_Expect100Continue(true);  //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;    System.Net.ServicePointManager::set_SecurityProtocol(System.Net.SecurityProtocolType::Tls12);  secProtocol = System.Net.ServicePointManager::get_SecurityProtocol();  ssl3 = secProtocol == enum2int(System.Net.SecurityProtocolType::Ssl3);  tls = secProtocol == enum2int(System.Net.SecurityProtocolType::Tls);  tls11 = secProtocol == enum2int(System.Net.SecurityProtocolType::Tls11);  tls12 = secProtocol == enum2int(System.Net.SecurityProtocolType::Tls12);  tls13 = secProtocol == 12288;     info(strFmt(/SSL3 enabled: '%1' | TLS enabled: '%2' | TLS1.1 enabled: '%3' | TLS1.2 enabled: '%4' | TLS1.3 enabled: '%5'/, ssl3, tls, tls11, tls12, tls13));     requestStream = request.GetRequestStream();  requestStream.Write(bytes, 0, bytes.get_Length());  response = request.GetResponse();  responseStream = response.GetResponseStream();  streamReader = new System.IO.StreamReader(responseStream);  responseJson = streamReader.ReadToEnd();  info(responseJson);}catch (Exception::CLRError){  ex = CLRInterop::getLastException().GetBaseException();  error(ex.get_Message());}
I have the same question (6)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 758 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 607 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 402 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans