I Have a web api that internally makes multiple web api calls and retuns one result at the end. These multiple methods take different time to execute and as a result I'm getting timeout exception in my function.
For ex:
DeleteAccount is my web api method and it calls another web api method DeleteExistingAccount. This DeleteExistingAccount has multiple method calls say method1, method2, method3, method4. As these are executing asynchronously I'm getting Timeout error in my DeleteAccount method.
How can I achieve the method1, method2, method3, method4 to execute synchronously one after the other.
/////This is my web api method
public IHttpActionResult DeleteAccount([FromUri] string acctId, [FromUri] string email = "")
{
if (PicUpHelper.IsValidUserRequest())
{
string baseUrl = System.Configuration.ConfigurationManager.AppSettings["APIURL"].ToString();
string url = string.Format("/api/deleteaccount/{0}", acctId);
var clientRequest = new RestClient(baseUrl);
var request = new RestRequest(url, Method.DELETE);
IRestResponse response = clientRequest.Execute(request);
//// When I look at the response I have the timeout here
var content = response.Content; // raw content
dynamic data = JsonConvert.DeserializeObject(content);
}
}
///My web api method will invoke this web api method
public WebApiResultEx<string, string> DeleteAccount([FromUri] string acctId, [FromUri] string email = "")
{
WebApiResultEx<string, string> oDelAcctRes = new WebApiResultEx<string, string>();
Account oAccountInfo = new Account();
MyDbContext DbCtxt = new MyDbContext();
AccountAPIController oAccountAPIController = new AccountAPIController();
var oAcctInfo = oPlatAccountAPIController.Get(acctId);
if (!oAcctInfo.HasError > 0)
{
oAcctInfo = (Models.Api.Account)(object)oAcctInfo.Data;
//second method
oRes = oAccountAPIController.DeleteAcct(acctId);
}
return oRes;
}
Thanks Tarak