Stream: dotnet
Topic: REST HTTP Response code
Richard Kavanagh (Jan 10 2018 at 23:14):
I'm using the .NET API to undertake a simple "GET" request via
try
{
Organization xx = client.Read<Organization>(url);
}
catch (Exception e)
{
throw;
}
In situations where the resource does not exist (i.e. a 404) an exception is thrown - in this case how do I get the HTTP response code?
Ewout Kramer (Jan 11 2018 at 09:03):
The exception you are catching is actually a FhirOperationException, so you could split your try/catch like so:
try
{
}
catch(FhirOperationException foe)
{
// inspect status
var httpStatus = foe.Status;
// get even more details
var operationOutcome = foe.Outcome;
}
catch(Exception e)
{
// something *really* bad happened
}
Richard Kavanagh (Jan 11 2018 at 10:07):
Perfect - thanks
Last updated: Apr 12 2022 at 19:14 UTC