Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

How to call an API via Code Activity Plugin on Microsoft Dynamics 365 Version 1612 (9.0.2.3034) (DB 9.0.2.3034) on-premises.

(0) ShareShare
ReportReport
Posted on by 185

Hi all,

I'm working on a CodeActivity for Microsoft Dynamics 365 Version 1612 (9.0.2.3034) (DB 9.0.2.3034) on-premises.
I am trying to call an API but It gives an "Unable to connect to the remote server" error. The code I wrote for that works fine in a console application, but it fails in the plugin. The code looks like the following: I am using .Net Framework 4.5.2.


string URL = "xxxxxx.xxxx.it/.../xxx
System.Net.WebClient webClient = new System.Net.WebClient();
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
webClient.Headers.Add("Authorization", "Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
var result = webClient.DownloadString(URL);

Can you guys help me?

  • Diana Birkelbach Profile Picture
    Diana Birkelbach 140 Most Valuable Professional on at
    RE: How to call an API via Code Activity Plugin on Microsoft Dynamics 365 Version 1612 (9.0.2.3034) (DB 9.0.2.3034) on-premises.

    It could be a Proxy issue, usually the PlugIn is running behind the firewall.

    I've made such calls using HttpClient

    HttpClientHandler handler = new HttpClientHandler();

    WebProxy proxy = new WebProxy( "xxx_proxyServer", port);

    handler.Proxy = proxy;

    using( HttpClient httpClient = new HttpClient(handler as HttpMessageHandler)){

    //....

    }

    As far as I remember, the "xxx_prosyServer" should be a name, not an IP.

    Hope this helps!

    Kind regards,

    Diana

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans