I am working with the Audiocodes SBC API which returns for example when no Alarms are available a 204 as response. This leads to FLurl GetJsonAsync request returning null. The problem now is how would one handle correctly this case? It is clear that there was no error as Flurl would have thrown an execption but as there is no return there also cannot be a mapping into a Json Object. My first idea to solve this was to check if the response would be 204 but I seem not to find where I can get the Response Code. Is there another way to do this or am I missing something?
To quote my own documentation verbatim:
Of course, you may want to inspect the response status independently of error-handling, or inspect other response properties such as headers. Using GetAsync, or just excluding the ReceiveXXX, from non-GET calls, returns an IFlurlResponse:
var resp1 = await "http://api.foo.com".GetAsync();
var resp2 = await "http://api.foo.com".PostJsonAsync(requestObj);
From which you can read other information before consuming the body:
int status = resp.StatusCode;
string headerVal = resp.Headers.FirstOrDefault("my-header");
T body = await resp.GetJsonAsync<T>();