0

I am trying to upload heavy file(200 mb) to sharepoint using python3.6, But getting below error. I am not sure if it is the issue with sharepoint path.

office365.runtime.client_request_exception.ClientRequestException: ('-2147024891, System.UnauthorizedAccessException', 'Access denied.', "403 Client Error: Forbidden for url: https://xyz.sharepoint.com/_api/Web/folders/Add('Testing%20')")

My piece of code:

from office365.runtime.auth.user_credential import UserCredential
from office365.sharepoint.client_context import ClientContext

def get_sharepoint_context_using_user():

    username='xyz@abc.com'
    password='password'
    # Get sharepoint credentials
    sharepoint_url = 'https://abx.sharepoint.com'

    # Initialize the client credentials
    user_credentials = UserCredential(username,password)

    # create client context object
    ctx = ClientContext(sharepoint_url).with_credentials(user_credentials)
    print(ctx)
    return ctx


def create_sharepoint_directory(dir_name: str):
    """
    Creates a folder in the sharepoint directory.
    """
    if dir_name:

        ctx = get_sharepoint_context_using_user()
        result = ctx.web.folders.add(f'{dir_name}').execute_query()

        


     create_sharepoint_directory('Testing')
Ashu
  • 193
  • 1
  • 16

1 Answers1

0

as of the error, it says you don't have access to the link, it might be the reason you might be using wrong credentials or might be the credentials you were using doesn't have write access but might only have read access.