SSIS脚本转换错误远程服务器返回错误:(407)需要代理身份验证



我正在使用SQL Server和Visual Studio 2019。我有一个SSIS包,它使用脚本转换作为从web服务提取数据的源(c#(。当我在笔记本电脑上通过Visual Studio执行时,一切都能100%正常工作。当我部署到SSIS目录并执行时,我一直收到错误:

Error The remote server returned an error: (407) Proxy Authentication Required

以下是我的代码片段:

public class ScriptMain : UserComponent
{
string json;
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public override void PreExecute()
{
base.PreExecute();
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

string fullurl = Variables.FullURL;
string url = fullurl;
json = DownloadJson(url);
}

我正在使用一个变量(上面的fullurl(构建url,该变量包括所有登录和密码信息。我需要修改它吗?还是公司网络上的某些东西阻止了它?

身份验证的方法很少出现在查询字符串中。可以,但通常不是。

试试这个。。。

var wc = new System.Net.WebClient();
wc.Credential = new NetworkCredential([username],[password]);
string json = wc.DownLoadString(url);

在PreExecute部分中这样做也是不常见的。通常在脚本组件源的添加行部分执行此操作。

最新更新