I am totally new to Flurl.I am trying to call api and i deliberately passed invalid apikey in paramter and then api fails saying "Forbidden" and with error code 403. How can i handle that in Exception?
public async Task<myResponse> MyService(myRequest request)
{
try
{
return await new Flurl.Url("https://myapi.com/rest/age?apikey=XXXXXXXX").PostJsonAsync(apirequest).ReceiveJson<myResponse>();
}
catch (FlurlHttpException ex)
{
var statusCode = await ex.GetResponseJsonAsync<myResponse>();
return await ex.GetResponseJsonAsync<myResponse>();
}
I want to throw my own custom exception if i get status code 403 but currently it fails on line var statusCode = await ex.GetResponseJsonAsync<myResponse>();
}