I need to save a sharepoint list as an excel/ csv file. To do so, I have followed following two SO links,
Get SharePoint List with Python
SharePlum error : "Can't get User Info List"
My code look like this,
import pandas as pd
from shareplum import Site
from requests_ntlm import HttpNtlmAuth
cred = HttpNtlmAuth("email_id", "password")
site = Site('https://companyname.sharepoint.com/sites/analyticsandml', auth=cred)
sp_list = site.List('Client Office List') # this creates SharePlum object
data = sp_list.GetListItems('All Items') # this will retrieve all items from list
data_df = pd.DataFrame(data[0:])
data_df.to_excel("data.xlsx")
print("Content of share point list is saved in a file.")
I'm getting the error below:
shareplum.errors.ShareplumRequestError: Shareplum HTTP Post Failed : 403 Client Error: Forbidden for url: https://companyname.sharepoint.com/sites/analyticsandml/_vti_bin/lists.asmx
Please help me with this.
Note: @Lee_MSFT on running your version of code, I get the error snapshot of which is below,
Traceback:
After using the shareplum based code, I get the following error,
My views: Shareplum based solution works when you use office365 with no other added layer of security like SecureAuth. If MFA is enabled, like in my case, it will give you invalid credentials error.