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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Plugin call External REST API - SSL/TSL could not create channel issue

(1) ShareShare
ReportReport
Posted on by 120

Hi All,

I have a task to call the external REST API to get data from thirt party application.

In that, i have created a C# Console application for tried this and it is working fine and i can get the data from thirt party application via REST API.

The same code used to tried in Dynamics Custom workflow\Plugin, i have got a error below. Please give your valubale suggestion on this.

"System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel."

Note: The below options are tried but no luck.

  • ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
  • ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(AlwaysGoodCertificate);
  • ServicePointManager.Expect100Continue = true;

Thanks,
Vasanth

I have the same question (0)
  • Vasanthkumar Profile Picture
    120 on at

    Hi All,

    I have a task to call the external REST API to get data from thirt party application.

    In that, i have created a C# Console application for tried this and it is working fine and i can get the data from thirty party application via REST API.

    The same code used to tried in Dynamics Custom workflow\Plugin, i have got a error below. Please give your valuable suggestion on this.

    "System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel."

    Note: The below options are tried but no luck.

    • ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
    • ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(AlwaysGoodCertificate);
    • ServicePointManager.Expect100Continue = true;

    Thanks,
    Vasanth

  • AriaConsulting Profile Picture
    2 on at

    Pretty sure one of the folks that knows a lot more about Dev than I do will correctly me, but I believe you have to use an OData connection on the D365 side.

  • Community Member Profile Picture
    on at

    Hi,

    Can you tell me what app you are using?

    Regards,

    Leah Ju

  • Suggested answer
    Wahaj Rashid Profile Picture
    11,321 on at

    Hi,

    Thank you for your query.

    This 3rd-party service you are trying to call is access by IP or a named URL?

    Please note accessing a resource using IP is not supported for the online versions, for example:

    Secondly, make sure this 3rd part service is secured using HTTPS protocol and a valid certificate.

    For your reference, here is a sample:

    PowerApps-Samples/cds/orgsvc/C#/WebAccessPlugin at master · microsoft/PowerApps-Samples · GitHub

    For further help, please share the sample code you are using.

  • Vasanthkumar Profile Picture
    120 on at

    Hi Wahaj,

    Thanks for your response.

    As you mentioned, i am using api url only not IP address. Also i have checked Third party end and they have confirmed that they dont have any certification and also they have used protocol 1.2

    App url :https://xxxxxx.onbmc.com/.../login

    Please refer below sample code for your reference

                  ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

                   HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://xxxxxxxx.onbmc.com/.../login");

                   request.Method = "POST";

                   request.UseDefaultCredentials = false;

                   request.ContentType = "application/x-www-form-urlencoded";

                   request.Timeout = 200000;

                   List<KeyValuePair<string, string>> allIputParams = new List<KeyValuePair<string, string>>();

                   allIputParams.Add(new KeyValuePair<string, string>("username", "xxxxxx"));

                   allIputParams.Add(new KeyValuePair<string, string>("password", "xxxxxxx"));

                   var formUrlEncodedContent = new FormUrlEncodedContent(allIputParams);

                   var urlEncodedString = formUrlEncodedContent.ReadAsStringAsync().Result;

                   using (var streamWriter = new StreamWriter(request.GetRequestStream()))

                   {

                       streamWriter.Write(urlEncodedString);

                   }                

                   request.ServicePoint.Expect100Continue = true;

                   HttpWebResponse httpResponse = (HttpWebResponse)(request.GetResponse());

                   StreamReader reader = new StreamReader(httpResponse.GetResponseStream());

                   var token = reader.ReadToEnd();

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 41 Most Valuable Professional

#2
iampranjal Profile Picture

iampranjal 39

#3
Satyam Prakash Profile Picture

Satyam Prakash 35

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans