Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 175888

"The request was aborted: Could not create SSL/TLS secure channel." On API Call

$
0
0

Hi,

I am facing an error "The request was aborted: Could not create SSL/TLS secure channel." on calling an API to send data to a 3rd party application.
I found similar queries on community but those fixes doesn't worked for me.

The version of TLS is 1.2 on my local hosted VM. (Note: it doesn't work on UAT and Production as well).

please help me out with this one.

Thanks

Here is code that I am using:

		try
        {
            httpHeader = new System.Net.WebHeaderCollection();
            new InteropPermission(InteropKind::ClrInterop).assert();

            clrObj = System.Net.WebRequest::Create("URL");
            request = clrObj;

            // adding headers

            byteStr = System.Convert::ToBase64String(System.Text.Encoding::Default.GetBytes(user + ":" + pass));

            httpHeader.Add("Accept-Version", "V2");
            httpHeader.Add("Clearance-Status", "1");
            httpHeader.Add("Accept-Language", "en");
            httpHeader.Add("Authorization", 'Basic ' + byteStr);

            

            request.set_Headers(httpHeader);

            request.Method = "POST";
            request.ContentType = "application/json";

            requestStream = request.GetRequestStream();
            streamWriter = new System.IO.StreamWriter(request.GetRequestStream());

            streamWriter.Write(jsonBody); // writing JSON
            

            response = request.GetResponse();

            streamWriter.Flush();
            streamWriter.Close();
            System.IO.StreamReader streamRead = new System.IO.StreamReader(response.GetResponseStream());

            Map responseMap = RetailCommonWebAPI::getMapFromJsonString(streamRead.ReadToEnd());

            MapEnumerator mapenum = responseMap.getEnumerator();
            /* Some code to validate the result */
        }
        catch
        {
            //exception
            ex = CLRInterop::getLastException().GetBaseException();
            error(ex.get_Message());
        }

Viewing all articles
Browse latest Browse all 175888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>