0

I am a newbie in c#. So for an etl, I am using SSIS component to fetch the data fusing API key and combine the fetched data with data from other sources.

so I am using the SSIS 'Script Component' to fetch the API data using the below code.

    public override void CreateNewOutputRows()
    {
        
        string url = String.Format(<url>);
        WebRequest requestObject = WebRequest.Create(url);
        
        requestObject.Credentials = new System.Net.NetworkCredential("username", "password");

        requestObject.Method = "GET";
        HttpWebResponse responseObject = null;
        responseObject = (HttpWebResponse)requestObject.GetResponse();

        string result = null;
        using (Stream stream = responseObject.GetResponseStream())
        {
            StreamReader sr = new StreamReader(stream);
            result = sr.ReadToEnd();
            sr.Close();
        }

        var serializer = new JavaScriptSerializer();
        var data = serializer.Deserialize<ResultApi>(result);// ResultApi class

        Output0Buffer.AddRow();
        Output0Buffer.Names = data.Names;

and my class is as below

 class ResultApi
    {
        public string Names { get; set; }
    }

I don't know what I am doing wrong but when running the SSIS package, I am getting the below error:

Error Message

It would a great help if someone can help me with this. Any advice or suggestion is appreciated. Thank you so much!

Deeins
  • 1
  • Please post the error don't screenshot it. But I would've thought "unable to connect to the remote server" was pretty obvious? Have you tested that you can reach the required URL from the server that the SSIS package is running on? – Nick.Mc Oct 10 '22 at 11:56
  • @Nick.McDermaid Thank you for your response and sorry for the wrong error screenshot. . and yes I tried to reach the url from the same server and it was successful. And my Error message is : -----The request was aborted: Could not create SSL/TLS secure channel.------ at System.Net.HttpWebRequest.GetResponse() at ScriptMain.CreateNewOutputRows() at UserComponent.PrimeOutput(Int32 Outputs, Int32[] OutputIDs, PipelineBuffer[] Buffers, OutputNameMap OutputMap) at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PrimeOutput(Int32 outputs, Int32[] outputIDs, PipelineBuffer[] buffers) – Deeins Oct 10 '22 at 21:46
  • Add ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; before calling. – KeithL Oct 10 '22 at 23:14

0 Answers0