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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Plugin REST API integration/Call

(0) ShareShare
ReportReport
Posted on by

Hi guys, 

I have a bit of a weird problem here. 

Scenario:

I need to make Calls to an external REST API from inside Dynamics 365 online. Wrote a test console app and I am able to make all the necessary calls to the external REST API.

The moment I make that a Plugin and register on D365, nothing works.

I get the below error:

“A Web exception occurred while attempting to issue the request. Unable to connect to the remote server

I contacted the third party and they confirmed that the port they are using is port 443.

Any ideas?

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Can you please provide the code you use?

  • Community Member Profile Picture
    on at

    try 
    {
    	using (WebClient client = new WebClient()) 
    	{
    		client.Headers.Add("Authorization", "Bearer Token Value");
    		client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
    		byte[] responseBytes = client.DownloadData("">api-XXXXXXXX.com/.../00");
    		string response = Encoding.UTF8.GetString(responseBytes);
    		tracer.Trace("Response : "   response); 
    	}
    } 
    catch (WebException exception) 
    { 
    	string str = string.Empty; 
    	if (exception.Response != null) 
    	{ 
    		using (StreamReader reader = new StreamReader(exception.Response.GetResponseStream())) 
    		{ 
    			str = reader.ReadToEnd(); 
    		} 
    		exception.Response.Close(); 
    	} 
    
    	if (exception.Status == WebExceptionStatus.Timeout) 
    	{ 
    		throw new InvalidPluginExecutionException( "The timeout elapsed while attempting to issue the request.", exception); 
    	}
    
    	throw new InvalidPluginExecutionException(String.Format(CultureInfo.InvariantCulture, "A Web exception occurred while attempting to issue the request. {0}: {1}", exception.Message, str), exception); 
    }

  • Community Member Profile Picture
    on at

    Apologies, Tried formatting the code snippet, didn't win.

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    No worries, I fixed the formatting.

    I remember having similar issues when I used WebClient. Check this post - stackoverflow.com/.../call-external-api-from-microsoft-dynamics-365-online

    I remember that using of HttpWebRequest/HttpWebResponse fixed the issue.

  • Community Member Profile Picture
    on at

    Thanks for this, appreciated. 

    There clearly is something totally wrong here. I used HttpWebRequest/HttpWebResponse (In console) works perfectly. deploy plugin, still getting my initial error "Unable to connect to remote server"

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://apiXXXXXX.com/.../00");
    request.ContentType = "application/json";
    request.Method = "GET";
    request.Timeout = 500000;
    
    request.Headers.Add("Authorization", "Bearer Token Value");
    var response = (HttpWebResponse)request.GetResponse();
    string content = string.Empty;
    using (var stream = response.GetResponseStream())
    {
    	using (var sr = new StreamReader(stream))
    	{
    		content = sr.ReadToEnd();
    	}
    }
    tracer.Trace("Response : "   content);

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    I would recommend to get in touch with API provider and ask if there is a need to whitelist IP addresses of Dynamics because the call to their API comes from it.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Pallavi Phade Profile Picture

Pallavi Phade 102 Super User 2026 Season 1

#2
ManoVerse Profile Picture

ManoVerse 58 Super User 2026 Season 1

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 55 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans