Witam wszystkich

Zmagam się z problemem wysłania poprzez resta pliku/ów na wykupioną usługę onedrive 365 office (sharepoint), według tego kody :

#Import required packages
import sys
import requests
from requests_ntlm import HttpNtlmAuth
 
#Read filename (relative path) from command line
fileName = sys.argv[1]
 
#Enter your SharePoint site and target library
sharePointUrl = 'https://your.sharepointsite.com'
folderUrl = '/Your/SharePoint/DocumentLibrary'
 
#Sets up the url for requesting a file upload
requestUrl = sharePointUrl + '/_api/web/getfolderbyserverrelativeurl(\'' + folderUrl + '\')/Files/add(url=\'' + fileName + '\',overwrite=true)'
 
#Read in the file that we are going to upload
file = open(fileName, 'rb')
 
#Setup the required headers for communicating with SharePoint 
headers = {'Content-Type': 'application/json; odata=verbose', 'accept': 'application/json;odata=verbose'}
 
#Execute a request to get the FormDigestValue. This will be used to authenticate our upload request
r = requests.post(sharePointUrl + "/_api/contextinfo",auth=HttpNtlmAuth('Domain\\username','password'), headers=headers)
formDigestValue = r.json()['d']['GetContextWebInformation']['FormDigestValue']
 
#Update headers to use the newly acquired FormDigestValue
headers = {'Content-Type': 'application/json; odata=verbose', 'accept': 'application/json;odata=verbose', 'x-requestdigest' : formDigestValue}
 
#Execute the request. If you run into issues, inspect the contents of uploadResult
uploadResult = requests.post(requestUrl,auth=HttpNtlmAuth('Domain\\username','password'), headers=headers, data=file.read())


Niestety kod wykrzacza się w lini "formDigestValue = r.json()['d']['GetContextWebInformation']['FormDigestValue'] " o błędzie :
form_digest_value = r.json()['d']['GetContextWebInformation']['FormDigestVal
ue']
KeyError: 'd'

PRosiłbym o wsparcie, oczywiście jeżeli ktoś ma inny sposób na wysłanie plików do onedrive poprzez pythona , albo inaczej ale z cli linuxa prosiłbym o namiary.

Pozdrawiam