Dear members,
At the moment I am having a System.Security.Permission problem (Request Failed message). I want to send a web API service message via a plugin. This must be done via an HttpRequest object because an SSL connection has to be set up. The plugin is executed in a sandbox.
In the HttpRequest object, which is an implementation of a WebClient object, a certificate is also included.
Code snippet:
internal class EngieApiWebClient : WebClient
{
private readonly IOrganizationService _organizationservice;
public ApiWebClient(IOrganizationService service)
{
_organizationservice = service;
}
protected override WebRequest GetWebRequest(Uri address)
{
// Get the request...
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address);
// ...and add the certificate
AuthCertificate.GetCertificate(_organizationservice);
request.ClientCertificates.Add(AuthCertificate.Certificate);
// Return the request
return request;
}
}
The call in the plugin is:
using (var wc = new ApiWebClient(CrmOrganisationService))
{
try
{
var data = wc.DownloadString($"{WebApiUrl}{SearchMethod}/{Postalcode}/{Housenumber}");
if (data.Length > 0) {
ConnectionResult connections = JsonConvert.DeserializeObject<ConnectionResult>(data);
if (connections.IsSuccess)
{
connections.Result.ForEach(c =>
{
CreateConnectionInCRM(c);
}
});
}
}
catch (WebException we)
{ }
}
}
ConnectionResult is a Model Class.
What should i do to solve the problem so the plugin will execute normally without permission exceptions.
Regards,
Hans
*This post is locked for comments