hi,
I need to call an external webservice from within a Dynamics CE Online Plugin.
The code just works fine when I run it in a console-app.
But when I run it inside the plugin (on create) I get the following error:
System.AggregateException: One or more errors occurred. --->
System.Net.Http.HttpRequestException: An error occurred while sending the request. --->
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection
failed because connected host has failed to respond xxx.xxx.xxx.xxx:443
This is the code to consume the webservice:
private async Task PostAsync(string relativeUrl, object data, string mediaType)
{
var jsonString = JsonSerializer.Serialize(data);
var content = new StringContent(jsonString, Encoding.UTF8, mediaType);
var result = await _httpClient.PostAsync(relativeUrl, content).ConfigureAwait(false);
var resultString = await result.Content.ReadAsStringAsync().ConfigureAwait(false);
Log("result=" resultString);
result.EnsureSuccessStatusCode();
var resultObject = JsonSerializer.Deserialize(resultString);
return resultObject;
}
Its an https-webservice.
Any ideas?