We recently uplifted our Epicor API from .NET Framework 4.8 to .NET 8. I have a snippet of code that used to work, but a change made to the EpicorRestV1 library is now causing a break:
respData = EpicorRestV1.DynamicPost("Erp.BO.CustShipSvc", "UpdateMaster", postData);
if (respData.HttpStatus != null)
{
if ((respData.HttpStatus == 400) || (respData.HttpStatus == 500))
{
String errorMsg = respData.ReasonPhrase.Value + " " + respData.ErrorMessage.Value;
throw new Exception("Erp.BO.CustShipSvc[Prep]: " + errorMsg);
}
}
Unfortunately, if the request responds with a “BadRequest” Http Status, the EpicorRestV1.DynamicPost(“”) library will throw an exception. This prevents me from actually seeing the error in the response body. In my case, my Bad Requests are a result of misconfigured products. It would be useful to be able to inform our Epicor users that a product needs some corrections, but unfortunately, because the exception is thrown before the response content is returned, I can’t actually know for certain what the error is.
I am (attempting to) attach a screenshot of the EpicorRestV1 PostJSON code to show where it returns the error
I am wondering if there is a work around that will allow me to see the error in the response instead of throwing the exception.