首页 > 解决方案 > RestRequest 在 Postman 中工作,但在 C# 中给出 403 Forbidden 错误

问题描述

我正在使用 RestSharp 在 C# 中获取 url 的响应,但总是给出 403 Forbidden 错误。在 Postman 中它运行良好,我获得了 200 成功。这是我在 C# 中的代码:

var client = new RestClient("https://data.fei.org/Calendar/ShowDetail.aspx?p=17C909D981B698168E94ACB4EB1963B1");
var request = new RestRequest(Method.GET);
request.AddHeader("postman-token", "45b65980-83be-7d2f-a60d-e1238dbd9417");
request.AddHeader("cache-control", "no-cache");
IRestResponse response = client.Execute(request);

我做错了什么来得到这个错误?

邮递员图片链接

标签: c#postmanrestsharp

解决方案


推荐阅读