为什么postman发出的请求可以正常响应但是C#就不行

7 篇文章 0 订阅

C#使用postman框架发送请求

GET请求在使用RestSharp时不产生响应,但在Postman中获得响应

为什么postman发出的请求可以正常响应但是C#就不行

postman中post请求正常,但是利用postman生成C#后台http模拟代码之后调用失败问题记录

postman中post请求正常,但是利用postman生成C#后台代码无响应

为什么它在Postman中可以工作,而在我的C#代码中却不能

var url = string.Format("https://xx.html", id, xianlu, ep);
 var htmlText = "";
 Sharing.setTips("动漫id已发出请求..."); 
 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
 var client = new RestClient(url);
 client.Timeout = -1;
 var request = new RestRequest(Method.GET);
 request.AddHeader("Authorization", "Bearer tokenComesHere");
 IRestResponse response = client.Execute(request);
 htmlText = response.Content;

原因1. 需要加  ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

2. 需要加请求头

3.目标网站本身的问题

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

星尘库

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值