使用python应用程序将文件上载到sharepoint online时将错误获取为错误请求
我试图通过RESTAPI使用python应用程序将文件上载到sharepoint o365,但出现错误 谢谢你的帮助 提前谢谢 请在下面找到脚本 代码:使用python应用程序将文件上载到sharepoint online时将错误获取为错误请求,python,python-2.7,sharepoint,sharepoint-online,office365-restapi,Python,Python 2.7,Sharepoint,Sharepoint Online,Office365 Restapi,我试图通过RESTAPI使用python应用程序将文件上载到sharepoint o365,但出现错误 谢谢你的帮助 提前谢谢 请在下面找到脚本 代码: 要与Microsoft Sharepoint交互,您需要使用Microsoft Graph API 这是它的主页 从驱动器中获取文件 另一种选择是使用OneDrive API 导入请求 def handle_file_upload(file_to_upload): """ Function to upload files to our
要与Microsoft Sharepoint交互,您需要使用Microsoft Graph API 这是它的主页 从驱动器中获取文件 另一种选择是使用OneDrive API 导入请求
def handle_file_upload(file_to_upload):
""" Function to upload files to our sharepoint directory """
# Getting the authenticated user credentials from python-social-auth
# This call assumes the user you are trying to access is the logged in user.
social = request.user.social_auth.get(provider='azuread-oauth2')
access_token = social.extra_data['access_token']
# build our header for the api call
headers = {
'Authorization' : 'Bearer {0}'.format(access_token),
}
# build the url for the api call
# Look at https://dev.onedrive.com/items/upload_put.htm for reference
url = settings.SOCIAL_AUTH_AZUREAD_OAUTH2_RESOURCE + '/_api/v2.0/drive/root:/' + file_to_upload.name + ':/content'
# Make the api call
response = requests.put(url, data=open(file_to_upload, 'rb'), headers=headers)
return response
要与Microsoft Sharepoint交互,您需要使用Microsoft Graph API 这是它的主页 从驱动器中获取文件 另一种选择是使用OneDrive API 导入请求
def handle_file_upload(file_to_upload):
""" Function to upload files to our sharepoint directory """
# Getting the authenticated user credentials from python-social-auth
# This call assumes the user you are trying to access is the logged in user.
social = request.user.social_auth.get(provider='azuread-oauth2')
access_token = social.extra_data['access_token']
# build our header for the api call
headers = {
'Authorization' : 'Bearer {0}'.format(access_token),
}
# build the url for the api call
# Look at https://dev.onedrive.com/items/upload_put.htm for reference
url = settings.SOCIAL_AUTH_AZUREAD_OAUTH2_RESOURCE + '/_api/v2.0/drive/root:/' + file_to_upload.name + ':/content'
# Make the api call
response = requests.put(url, data=open(file_to_upload, 'rb'), headers=headers)
return response
我建议使用来访问Microsoft Sharepoint。
遗憾的是,缺少有关Sharepoint操作的文档,但我可以确认它是否有效。我建议使用它访问Microsoft Sharepoint。
遗憾的是,缺少Sharepoint操作文档,但我可以确认它是否有效。它如何帮助将文档上载到Sharepoint online它如何帮助将文档上载到Sharepoint online