aprs
aprs

Reputation: 1

Unable to download from https Sharepoint online with SSIS

I am struggling with this task. I need to download one file (excel) from SharePoint online and I cant install extra features so I am trying do it in HTTP connection.

The problem is that HTTP connection in SSIS give me code error 403 and I don't understand what to fix it.

I have an Microsoft account in SharePoint where I have permissions. I am using HTTP connection manager editor with credentials but I am not sure if the domain is right.

Upvotes: 0

Views: 2618

Answers (1)

Nick Noodle
Nick Noodle

Reputation: 11

Took me quite a while to get to grips with this so for anyone else who is struggling, the following worked for me:

    Using wc As New WebClient
        wc.Credentials = New SharePointOnlineCredentials(usr, spwd)
        wc.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
        wc.DownloadFile(source, target)
    End Using

Specifically, I needed to use SharePointOnlineCredentials rather than System.Net.NetworkCredential, and was still getting the 403 error until I added the wc.Headers.Add() line.

For info, I'm using:

So for completeness, the other bits you need are:

Imports System.Net
Imports System.Security
Imports Microsoft.SharePoint.Client
...
 Dim pwd As String = "password"
 Dim cpwd As Char() = pwd.ToCharArray()
 Dim spwd As New SecureString()
 For Each c As Char In cpwd
      spwd.AppendChar(c)
 Next

Upvotes: 1

Related Questions