![](/img/trans.png)
[英](400) Bad Request -> The remote server returned an error: (400) Bad Request
[英]the remote server returned an error (400) bad request
我正在尝试通过使用RSS源URL来生成XML格式的数据。 我有一个例外:
远程服务器返回错误(400)错误的请求错误。
我正在使用SSIS包,并在控制流中创建了一个安全任务,我编写的脚本如下:
public bool DownloadFeed()
{
string user = "xxx";
string password = "pwd";
WebClient web = new WebClient();
System.Net.WebClient wc = new System.Net.WebClient();
wc.Credentials = new System.Net.NetworkCredential(user, password);
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3 |
SecurityProtocolType.Tls |
SecurityProtocolType.Tls11 |
SecurityProtocolType.Tls12;
wc.DownloadFile(@"https://Entered RSS Feed URL here", @"H:\import\Test.xml");
return true;
}
这可能是格式化凭据并将其传递到服务器的方式。 你可以试试这个吗?
using System.Net;
public bool DownloadFeed()
{
string user = "xxx";
string password = "pwd";
System.Net.WebClient wc = new System.Net.WebClient();
string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(user + ":" + password));
wc.Headers[HttpRequestHeader.Authorization] = "Basic " + credentials;
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3 |
SecurityProtocolType.Tls |
SecurityProtocolType.Tls11 |
SecurityProtocolType.Tls12;
wc.DownloadFile(@"https://Entered RSS Feed URL here", @"H:\import\Test.xml");
return true;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.