1

Having problem with accessing sharepoint via rest api.

Hi!

I'm trying to use REST API to access company SharePoint Online in Python.

For instance, the SharePoint folder I want to access is:https://company.sharepoint.com/sites/sitename/foldername. I have access to the site, and the folder, but no access to the company root.

I tried two methods:

Option 1: HttpNtlmAuth

domain = ' https://company.sharepoint.com/'

url = ' https://marvell.sharepoint.com/sites/sse/_api/web/lists/GetByTitle(\'Sandbox\')/items'

actual_username = domain + username

response = requests.get(sharePointUrl,auth= HttpNtlmAuth(actual_username,password))

Option 2: sharepy

s = sharepy.connect("company.sharepoint.com")

But both of them fails, and I get either 403, Forbidden, or 401 Client Error: Unauthorized for url.

Can anyone help to check what might be the issue here?

Thanks in advance!

C.

Oblivion
  • 7,176
  • 2
  • 14
  • 33
Celine
  • 11
  • 1
  • 2

1 Answers1

-2

The following solutions with source code from GitHub for your reference.

Office 365 API SDK for Python

SharePy - Simple SharePoint Online authentication for Python

LZ_MSFT
  • 4,079
  • 1
  • 8
  • 9