Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Unable to Connect to Remote Server from CRM Plugin

Posted on by Microsoft Employee

Hi,

I am trying to call https webservice with basic authentication request.

I tried using below code, but i am getting an error.

var request = WebRequest.Create(new Uri("intkgpdj.service.svc/CloseTask"));
request.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " +
Convert.ToBase64String(Encoding.ASCII.GetBytes(@"domain\username"+ password));

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


string postData = @"
{
'TaskRequest':
[
{
'Field1': 'answerValue', 'Field2': 'value12', 'field3' : 'true', 'ApplicationData':[{ 'ApplicationId': 'value11', 'ApplicationKey': 'value12'}]
}
]

}";

byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentLength = byteArray.Length;
System.IO.Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
using (var response = request.GetResponse())
{
responseText = new StreamReader(response.GetResponseStream()).ReadToEnd();
}

Please help.

thanks

*This post is locked for comments

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Unable to Connect to Remote Server from CRM Plugin

    Try specify the full url in the WebRequest.Create:

    var request = WebRequest.Create(new Uri("https://intkgpdj.service.svc/CloseTask"));

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Unable to Connect to Remote Server from CRM Plugin

    Are you online or on-prem?

    If you're online and your service is not available from outside of the network - you will have to publish it.

    If you're on-prem - sounds like network issue for me.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Unable to Connect to Remote Server from CRM Plugin

    this is the URL - https://intkgpdj.service.svc

    Method is - CloseTask

    The URL works only within our network..!

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Unable to Connect to Remote Server from CRM Plugin

    Hello,

    In your code you used following url - intkgpdj.service.svc/CloseTask

    Are you 100% sure that you use correct url? I tried to lookup that domain name using nslookup and I got "can't find intkgpdj.service.svc: Non-existent domain" reply.

    Doublecheck that you use correct url.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Unable to Connect to Remote Server from CRM Plugin

    Unable to connect to remote server..

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Unable to Connect to Remote Server from CRM Plugin

    Hello,

    What exception do you get?

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

Featured topics

Product updates

Dynamics 365 release plans