How to upload files to Sharepoint Online using SSIS

Nicky 121 Reputation points
2020-09-30T22:13:37.317+00:00

Hi

I run a SSIS package every week on VM. I have a set of csv files which I want to upload to Sharepoint online in sq shared documents. I am able to Archive those files on local machine but not able to upload to Sharepoint.

How ca I achieve this without using third party tool. Any help will be appreciated.
visua
Thanks in advance!
nikz

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,702 questions
SQL Server Other
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Monalv-MSFT 5,926 Reputation points
    2020-10-01T01:44:53.727+00:00

    Hi @InderjeetKaur-3272,

    Please upload files to Sharepoint Online using SSIS Script Task.

    The following links will be helpful:

    Lists.UpdateList Method

    Uploading documents to WSS (Windows Sharepoint Services) using SSIS

    SSIS: Upload file to Sharepoint Document Library (revisited)

    Upload zipped files to SharePoint Document Library Office 365 using SSIS (vb.net / C#.net)

    Best Regards,
    Mona

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

  2. Nicky 121 Reputation points
    2020-10-01T09:44:03.857+00:00

    Hi

    I am using this code in script task editor. I a getting error "Remote server returned an error: 403 forbidden"

    public void Main()
    {
    // TODO: Add your code here
    // var DestinationFolder = Dts.Variables["User::DestinationFolder"].Value.ToString();

            //if (!Directory.Exists(DestinationFolder))
            //{
            //    Directory.CreateDirectory(DestinationFolder);
            //}
            //Dts.TaskResult = (int)ScriptResults.Success;
    
    
            WebClient myWebClient;
            string DestinationURL;
            string LocalFileName;           
            bool FireAgain = true;
    
            try
    
            {
    
                myWebClient = new WebClient();
                LocalFileName = @"C:\Foldername\Filename.csv";
    
                DestinationURL = @"https://sharepointsitename/sites/TeamsFolder/Shared Documents/General/Folder Name/Filename.csv";
    
                Console.WriteLine(LocalFileName);
    
                myWebClient.Credentials = new NetworkCredential("userid", "password","domainname");
                myWebClient.Credentials = CredentialCache.DefaultNetworkCredentials;
    
                Dts.Events.FireInformation(0, String.Empty, String.Format("Uploading {0} to {1}", LocalFileName, DestinationURL), String.Empty, 0, ref FireAgain);
    
                // upload the file
    
                myWebClient.UploadFile(DestinationURL,"PUT", LocalFileName);
    
            }
            catch (Exception ex)
            {
                // Catch and handle error
                Dts.Events.FireError(0, String.Empty, ex.Message, String.Empty, 0);
                MessageBox.Show(DestinationURL);
                MessageBox.Show(ex.Message);
            }
        }
    

    Thanks

    Nikz


  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.