Background
Currently creating a web api which will need to talk to another web api which I have created. This problematic web api is out the box and the only changed I have mad is to enable cores and added two classes to it.
Problem
Currently this web api is executing all the way to my integration point however when it hits HttpResponseMessage hrm = await hc.GetAsync(requestUrl);
it stops and does not give me an error. I tried putting a try catch on that function however it ignores that try catch aswell. The following code will show how I am building this web api.
Code
Controller
[Route("api/WorkingPaperServices/CreateWorkingPaper")]
public IHttpActionResult CreateWorkingPaper()
{
try
{
log4net.Config.XmlConfigurator.Configure();
bool complete = WorkingPaperCreator.StartWPCreation().Result;
return Ok("Finished");
}
catch(Exception ex)
{
log4net.LogManager.GetLogger("EmailLogger").Error(JsonConvert.SerializeObject(ex));
return ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Not Laoded"));
}
}
WorkingPaperCreator - class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
namespace CWAppServices.Services
{
public class WorkingPaperCreator
{
public static async Task<bool> StartWPCreation()
{
try
{
var testing = await IntergrationPoints.GetClientInformation();
return true;
}
catch(Exception ex)
{
return false;
}
}
}
}
IntergrationPoints - class (Where my problem is)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web;
namespace CWAppServices.Services
{
public class IntergrationPoints
{
public static async Task<bool> GetClientInformation()
{
List<string> uniqueID = new List<string>();
try
{
string requestUrl = "http://appdev.tenant.com/caseware32/api/DataServices/GetAllClients";
var action = new HttpMethod("GET");
HttpClient hc = new HttpClient();
HttpResponseMessage hrm = await hc.GetAsync(requestUrl);
if (hrm.IsSuccessStatusCode)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
// TODO Log
return false;
}
}
}
}