title: Perform HTTP get operation in SSIS to fetch information from an API
body: <p>I'm working on an SSIS package to get some information from an API. Is there any component or an extension that I can use in SSIS to perform HTTP Request or Response operation. My <strong><a href="https://virtserver.swaggerhub.com/Monish/Disenrollment/1.0.0/inventory?searchString=7S6012-000001" rel="nofollow noreferrer">API is in JSON format</a></strong>. It has two fields ID and date. I'm trying to get the 'date' field by providing the ID.</p>
  
  <p>I'm new to c# and SSIS. Please let me know if I should I try with the script component or is there any alternative extension in SSIS to do this.</p>
  
  <p>Using the script component in SSIS here is what I have tried.</p>
  
  <p>Here is what I've tried after referring <a href="http://dennysjymbo.blogspot.com/2013/05/using-json-feed-as-data-source-in-ssis.html" rel="nofollow noreferrer">this</a> article.</p>
  
  <pre><code>public override void CreateNewOutputRows()
  {
      string serviceDate = Variables.TaskID;
      string wUrl = "https://virtserver.swaggerhub.com/Monish/Disenrollment/1.0.0/inventory?searchString=" + serviceDate;
  
      try
      {
          WorkGroupMetric[] outPutMetrics = GetWebServiceResult(wUrl);
  
          foreach( var metric in outPutMetrics)
          {
              Output0Buffer.AddRow();
              Output0Buffer.DisenrollmentDate = metric.CN;
  
  
          }
      }
      catch (Exception e)
      {
          FailComponent(e.ToString());
      }
  
  }
  
  private WorkGroupMetric[] GetWebServiceResult(string wUrl)
  {
      HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create(wUrl);
      HttpWebResponse httpWResp = (HttpWebResponse)httpWReq.GetResponse();
      WorkGroupMetric[] jsonResponse = null;
  
      try
      {
          //Test the connection
          if(httpWResp.StatusCode == HttpStatusCode.OK)
          {
              Stream responseStream = httpWResp.GetResponseStream();
              string jsonString = null;
  
              //Set jsonString
              using (StreamReader reader = new StreamReader(responseStream))
              {
                  jsonString = reader.ReadToEnd().Replace("\\", "");
                  reader.Close();
              }
  
              //Desearialize our JSON
              JavaScriptSerializer sr = new JavaScriptSerializer();
  
              jsonResponse = sr.Deserialize&lt;WorkGroupMetric[]&gt;(jsonString.Trim('"'));
  
          }
          //Output connection error message
          else
          {
              FailComponent(httpWResp.StatusCode.ToString());
          }
      }
      catch (Exception e)
      {
          FailComponent(e.ToString());
      }
      return jsonResponse;
  }
  </code></pre>