How to download from a dynamic link using SSIS?

  • Hi everyone,

    So I have a ssis package in which I download a excel file and import the contents of the file to SQL tables.

    Issue I am facing is that the download link changes of the file frequently.

    Today the download link is:

    https://www.uaeiec.gov.ae/API/Upload/DownloadFile?FileID=34cb35aa-3ba6-4e18-a950-f2b66f1cdf15

    But tomorrow the "FileID=" will change as new file will be uploaded here:

    https://www.uaeiec.gov.ae/en-us/un-page?p=1

    123

     

    Below is the code for downloading the file:

    How can I get the latest download link? Can anyone help me?

     

      public void Main()
    {

    ServicePointManager.Expect100Continue = true;
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;


    try
    {


    //below code is for downloading UAE_LTL xls data
    string myURI5 = "https://www.uaeiec.gov.ae/API/Upload/DownloadFile?FileID=34a55617-5e44-49cd-985d-a56d2f2f85cd";
    string forSDN5 = "LS 230222.xls";
    string myWebString5 = null, myLocalPath5 = null;
    //forSDN4 = forSDN4.Replace(forSDN4, "sdn_xml.zip");
    myWebString5 = myURI5;// + forSDN5;
    myLocalPath5 = "D:\\6_downloaded_files\\" + forSDN5;
    WebClient myWebClient4 = new WebClient();
    myWebClient4.DownloadFile(myWebString5, myLocalPath5);

    }


    catch (Exception ex)
    {
    Dts.Events.FireError(18, "The process failed", ex.ToString(), "", 0);
    Dts.TaskResult = (int)ScriptResults.Failure;
    }
    }

    #region ScriptResults declaration
    /// <summary>
    /// This enum provides a convenient shorthand within the scope of this class for setting the
    /// result of the script.
    ///
    /// This code was generated automatically.
    /// </summary>
    enum ScriptResults
    {
    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    };
    #endregion

    }
    }

     

    • This topic was modified 1 year, 8 months ago by  Jobs90312.
  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply