SSIS Script Component Error while fetching from API

151 views Asked by At

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!

0

There are 0 answers