使用WebClient发送GET请求时没有发现错误
本文关键字:发现 错误 请求 WebClient 发送 GET 使用 | 更新日期: 2023-09-27 18:13:07
我试图发送GET请求到我的服务器,使用WebClient和获得错误的"未找到"。在c++中,同样的请求工作得很好。我的URL看起来像:
"https://www.example.com/something/something¶m1=data1¶m2={}"
…请求看起来像
WebClient client = new WebClient();
string res = client.DownloadString(url);
我做错了什么?
我成功了!我错过了标题。
我的URL看起来像"https://www.example.com/something/something?param1=data1¶m2={}"
WebClient client = new WebClient();
client.Headers.Add("Content-Type", "application/json");
client.Headers.Add("Accept-Version", "4");
client.Headers.Add("User-Agent", "v4.1.0.0");
string res = client.DownloadString(url);
Thanks for the help