简体   繁体   中英

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

I'm using SQL Server and Visual Studio 2019. I have a SSIS Package that uses a Script Transformation as a source (c#) that pulls data from a web service. When I execute via Visual Studio on my laptop it all works 100%. When I deploy to the SSIS Catalog and execute I keep receiving the error:

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

Here is a snippet of my code:

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);
    }

I'm building the url using a variable (fullurl in the above) that includes all the login and password info. Do I need to modify this or is it something on the company network blocking it?

the way to authenticate is rarely in the query string. It can be, but usually isn't.

Try this instead...

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

It is also unusual to do this in the PreExecute portion. You usually do this in the add rows portion of a Script Component source.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM