Hi Team,
I have parallel call as showed below, at present if other API is failed for one AccountID, then complete call considering as fail. Could you please let me know how I can make the call better, Even if one AccountID is failed still I need to continue with final response for the success AccountID.
- public async Task
- > Process(Dictionary<
- {
- List
tasks = new List (); - List
creditCardSummaryServiceList = new List (); - foreach (var permanentId in permanentIds)
- {
- CreditCardSummaryRequest request = new CreditCardSummaryRequest()
- {
- AccountID = permanentId.Key, // "00001528830094858440"
- AccountToken = permanentId.Value //token
- };
- tasks.Add(ModelServiceProcessing(request).ContinueWith(
- (TResult) => creditCardSummaryServiceList.Add(TResult.Result)));
- }
- await Task.WhenAll(tasks.ToArray());
- return creditCardSummaryServiceList;
- }
- public async Task
ModelServiceProcessing(CreditCardSummaryRequest request) - {
- //deleted some code for constructing header
- var restServiceResponse = await restClient.Post(ccStatusInfoUrl,request ,true, header); // this is the code to make a call to other API
- var restServiceResponseInformation = await restServiceResponse.Content.ReadAsStringAsync();
- if (!restServiceResponse.IsSuccessStatusCode)
- {
- throw new CallFailureException($"Call has been failed");
- }
- context.LogQueue.AddDebugMessage($"ICS CardSummary success for PId ending - {Common.GetLastFour(request.AccountID)}");
- var response = Common.DeSerializeObject
(restServiceResponseInformation, false); - return response;
- }
Replies
Know the answer? Post it — somebody with the same question will find it here.