Thanks for the link .
I have tried the code in this way for the "Get" method , but getting error at httprequest call.
code:
public class pluginwebclient :IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
try
{
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity entity = (Entity)context.InputParameters["Target"];
if (entity.LogicalName != "contact")
return;
string serviceUrl = string.Format("">dummy.restapiexample.com/.../1");
WebRequest request = WebRequest.Create(serviceUrl);
request.Method = "GET";
request.ContentType = "Application/Json";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string result = string.Empty;
using (Stream stream = response.GetResponseStream())
{
StreamReader sr = new StreamReader(stream);
result = sr.ReadToEnd();
sr.Close();
}
entity.Attributes.Add("jobtitle", result);
}
}
catch (Exception ex)
{
throw new InvalidPluginExecutionException(ex.Message);
}