RestSharp- 如何获取数字http响应代码?
如何检索实际的数字http响应代码?我不仅没有看到包含数字代码的属性,而且甚至在标题集合中也看不到它。
最佳答案:
2 个答案:
答案 0 :(得分:26)
只需从RestResponse对象中获取ResponseCode属性,然后将枚举值强制转换为int。
RestResponse response = client.Execute(request);
HttpStatusCode statusCode = response.StatusCode;
int numericStatusCode = (int)statusCode;
答案 1 :(得分:-2)
Assert.Equal(200, (int)response.StatusCode);
本文经用户投稿或网站收集转载,如有侵权请联系本站。