Xamarin.forms 如何在RestSharp.Portable中捕获错误401?
我在我的项目中使用RestSharp.Portable,我尝试捕获错误401,但是行client.Execute(request)生成了一个错误Xamarin.forms 如何在RestSharp.Portable中捕获错误401?,xamarin.forms,restsharp,Xamarin.forms,Restsharp,我在我的项目中使用RestSharp.Portable,我尝试捕获错误401,但是行client.Execute(request)生成了一个错误 var client = new RestClient(BaseUrl); client.IgnoreResponseStatusCode = false; var response = await client.Execute<T>(request); if (!response.IsSuccess)
var client = new RestClient(BaseUrl);
client.IgnoreResponseStatusCode = false;
var response = await client.Execute<T>(request);
if (!response.IsSuccess)
{
//Custom Exception using response.StatusCode
}
var-client=newrestclient(BaseUrl);
client.IgnoreResponseStatusCode=false;
var response=wait client.Execute(请求);
如果(!response.issucess)
{
//使用response.StatusCode的自定义异常
}
请阅读并相应编辑您的问题。你的错误是什么?为我们提供一个最小的可运行示例。“client.IgnoreResponseStatusCode=false;”尝试以下操作:“client.IgnoreResponseStatusCode=true;”参考:请阅读并相应地编辑您的问题。你的错误是什么?为我们提供一个最小的可运行示例。“client.IgnoreResponseStatusCode=false;”尝试以下操作:“client.IgnoreResponseStatusCode=true;”参考: