SSIS Visual Studio C# script component to access SharePoint returning 403 error

  Kiến thức lập trình

I was wondering if anyone can help point me in the right direction to resolve an issue that I’m currently having, trying to use SSIS script component (C#) to access a SharePoint (on-line) site’s permissions. There is a functioning connection to the SharePoint site which uses oAuth and the app has been given ‘full control’. The C# code is in an SSIS script component which uses the SharePoint connection.

Whenever the code execution reaches the line ‘context.ExecuteQuery();’ the 403 error is thrown. I stripped the code to the basics and the error is still occuring. This is the stripped down code:

public override void PreExecute()
{
    base.PreExecute();
    
    // Starting with ClientContext, the constructor requires a URL to the
    // server running SharePoint.
    ClientContext context = new ClientContext("https://companyname.sharepoint.com/sites/sitename/");

    // Execute the query to server.
    context.ExecuteQuery();
} 

I’m unsure what to try next to identify the problem and I’d greatly appreciate any help.

New contributor

user24120529 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT