C# Plugin calling an external REST API

Overview

This is a simple example of how a Dynamics 365 C# plugin can connect to an external REST API (i.e. sitting outside of the Dynamics 365 environment). (The class used to achieve this being the RestClient class.)

This post is similar to C# Application Connecting to Facebook

Detail

Based on my experience, it seems calling a REST API from a plugin can be a bit challenging. This could be based on security issues or perhaps the way Dynamics handles asynchronous code. Anyway, the code sample below works.

It represents a simple ‘action’ which was registered as ‘None’

and ‘PostOperation’

and tested with the CRM REST Builder tool