Not Found returning 405
Posted: Tue Nov 17, 2020 4:34 pm
I have the code below to return an image for a route it works fine but when you give it a bad inventory ID it is returning a 405 instead of a 404, it is definitely producing the RecordNotFoundException but just the wrong status code any ideas how to resolve this?
- Code: Select all
[Authenticate]
[AddHeader(ContentType = "image/png")]
public byte[] Get( ImageRequest request)
{
JiwaApplication.Manager manager = this.SessionAs<JiwaAuthUserSession>().Manager;
JiwaFinancials.Jiwa.JiwaInventory.Inventory inv = manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaInventory.Inventory>(null);
try
{
inv.Read(request.InventoryID);
}
catch(Exception ex)
{
throw new JiwaApplication.Exceptions.RecordNotFoundException("Product not found for " + request.InventoryID);
}
return inv.Picture;
}