RadhaKrishnaKiJaya
asked on
Windows event viewer logging the API error
Hi Experts,
When the following function runs, the windows event viewer is logging the attached error. Any help is greatly appriciated!
public void EndCheckForEisEmails(IAsyn cResult result) {
var response = ((ServiceResponsePaged<Eis Email>)((( ChannelInv okeAsyncRe sult)resul t).Result) );
if (response.Status == ResponseStatus.Success) {
var baseUrl = (string) result.AsyncState;
//We have to hit our own api to get a valid request context so that we can trigger the rule. Currently we have no request context
var apiUrl = string.Format("{0}/api/sit eevent/Sen dEisEmails ", baseUrl);
Thanks in advance.
var emails = response.PagedData;
var jsonFormatter = new JsonMediaTypeFormatter();
var client = new HttpClient();
//var responseMessage = client.GetAsync("Recycling ClaimsProc essed");
const int numberOfItemsToprocess = 20;
int pages = (emails.Count() / numberOfItemsToprocess) + 1;
for (var i = 0; i < pages; i++) {
var responseMessage =
client.PostAsync(apiUrl, emails.Skip(i*numberOfItem sToprocess ).Take(num berOfItems Toprocess) .ToArray() ,
jsonFormatter).Result;
//This forces a pause, this is by design, we don't want to create too many requests.
if (!responseMessage.IsSucces sStatusCod e) {
Logger.Error("Error while trying to post to SendEisEmails " + responseMessage.RequestMes sage);
}
}
}
EISError.txt
When the following function runs, the windows event viewer is logging the attached error. Any help is greatly appriciated!
public void EndCheckForEisEmails(IAsyn
var response = ((ServiceResponsePaged<Eis
if (response.Status == ResponseStatus.Success) {
var baseUrl = (string) result.AsyncState;
//We have to hit our own api to get a valid request context so that we can trigger the rule. Currently we have no request context
var apiUrl = string.Format("{0}/api/sit
Thanks in advance.
var emails = response.PagedData;
var jsonFormatter = new JsonMediaTypeFormatter();
var client = new HttpClient();
//var responseMessage = client.GetAsync("Recycling
const int numberOfItemsToprocess = 20;
int pages = (emails.Count() / numberOfItemsToprocess) + 1;
for (var i = 0; i < pages; i++) {
var responseMessage =
client.PostAsync(apiUrl, emails.Skip(i*numberOfItem
jsonFormatter).Result;
//This forces a pause, this is by design, we don't want to create too many requests.
if (!responseMessage.IsSucces
Logger.Error("Error while trying to post to SendEisEmails " + responseMessage.RequestMes
}
}
}
EISError.txt
ASKER
Thanks for your suggestion. I would definitely use the code button next time. I didn't know it was there.
Regarding the problem, it is a production error.I have not written this code. I do not have lots of flexibility to change any code. The problem is, one email is not going through when it is called using "client.PostAsync" and throwing that exception.
Thanks.
Regarding the problem, it is a production error.I have not written this code. I do not have lots of flexibility to change any code. The problem is, one email is not going through when it is called using "client.PostAsync" and throwing that exception.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your suggestion!!
Then: the log clearly states it..
You're method itself has no error handling, although it is using external, not reliable resources (HttpClient and call to the net).
The further obvious things are:
Thus the server you've called, has terminated the connection. Cause?? Maybe a malformed request, maybe you've already exceeded your quotas or even a real network issue.