c# - 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);
我做错了什么来得到这个错误?
解决方案
推荐阅读
- php - Symfony 4 / 学说插入初始数据库数据
- c - 这部分代码还有优化的空间吗?
- visual-studio-2017 - Nuget 输入不是有效的 Base-64 字符串,因为它包含非 base 64 字符,超过两个填充字符
- amazon-web-services - AWS API Gateway:API 密钥的最佳实践
- amazon-dynamodb - 是否可以使用 DynamoDB 存储后端横向扩展 Hashicorp Vault?
- resharper - 实现缺少的成员 - 当返回类型为任务时添加异步?
- python - 在文档字符串 sphinx 中添加字典键
- python - 如何使用 django-mysql 在 Django 中修复应用程序尚未加载的错误?
- javascript - 如何向 asmx webservice 发送请求
- dokuwiki - 如何在特定时间发送 DokuWiki 通知邮件?