0

I have some ethernet device which collect data and it's possible to download it via data export interface: HTTP-GET query returns the data in [Content-Type: text/plain Charset: utf-8]

I saw this: How to make an HTTP request from SSIS? - it rather doesn't work for me (C# is a little Chinese for me) and it's about how to fetch this data to variable into SSIS

everand76
  • 11
  • 1
  • 1
    This question is likely to get closed as you didn't really ask anything. But the easiest way to access an API is using WebClient in C#. 2 lines gets you the string. System.Net.WebClient wc = new WebClient(); string response = wc.DownloadString([url]); – KeithL Aug 05 '20 at 11:35
  • thank's - that works fine :) – everand76 Aug 06 '20 at 16:10

1 Answers1

0

In your SSIS package add a C# Script Task

Edit the Script Task

  1. At the top with the other using statements add using System.Net;
  2. in Main use the following code snippet to make a GET request (Note: Change "https://somewhere.com/contacts/get" to your actual endpoint.)
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://somewhere.com/contacts/get");
    request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

    using(HttpWebResponse response = (HttpWebResponse)request.GetResponse())
    using(Stream stream = response.GetResponseStream())
    using(StreamReader reader = new StreamReader(stream))
    {
        return reader.ReadToEnd();
    }

vvvv4d
  • 3,881
  • 1
  • 14
  • 18