Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Calling Rest Api From Plugin

(0) ShareShare
ReportReport
Posted on by

I have created a plugin which get activated when any new connection created.

And in plugin i am calling a REST api to store data in our OLD system.

But when i am calling  like below

bytes = Encoding.UTF8.GetBytes(PayLoad);

  1. using (var client = new WebClient())
  2. {
  3. client.Headers[HttpRequestHeader.Accept] = "application/json";
  4. client.Headers[HttpRequestHeader.ContentType] = "application/json";
  5. client.Encoding = Encoding.UTF8;
  6. var response = client.UploadData(RestUrl, "PUT", bytes);
  7. return Encoding.UTF8.GetString(response);
  8. }

But its not running and when i am debugging it comes on line 7 and when i hit F10 it getting stop and my Plugin Registration Tool also get crashed.

If it don't get crash i can get the exception but due to that i am unable to catch the cause.

Thanks,

Rahul tiwari

*This post is locked for comments

  • mluce Profile Picture
    302 on at
    RE: Calling Rest Api From Plugin

    Actually, if you log to the tracingservice the plugin actually carries on.  Its just the plugin registration tool does not seem to like web service calls like this.  I got around the issue by just being very verbose with the tracing service.

  • mluce Profile Picture
    302 on at
    RE: Calling Rest Api From Plugin

    Same issue here - did you ever find a solution?

  • prt33k Profile Picture
    6,907 on at
    RE: Calling Rest Api From Plugin

    What is the authentication mechanism for the service?

    Please note :

    Sandboxed plug-ins and custom workflow activities can access the network through the HTTP and HTTPS protocols. This capability provides support for accessing popular web resources like social sites, news feeds, web services, and more. The following web access restrictions apply to this sandbox capability.

    • Only the HTTP and HTTPS protocols are allowed.
    • Access to localhost (loopback) is not permitted.
    • IP addresses cannot be used. You must use a named web address that requires DNS name resolution.
    • Anonymous authentication is supported and recommended. There is no provision for prompting the logged on user for credentials or saving those credentials.

    https://msdn.microsoft.com/en-in/library/gg334752.aspx

    Thanks,

    PS

  • MMK Profile Picture
    745 on at
    RE: Calling Rest Api From Plugin

    I also came across the same situation what is the solution for this

  • MMK Profile Picture
    745 on at
    RE: Calling Rest Api From Plugin

    Came across the same situation what is the solution of this

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,207 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans