
[英]Error when trying to upload data to firebase using python program
[英]JSONDecode error when trying to upload files to sharepoint by using a python script
我一直在尝试将 excel 文件上传到 sharepoint 文件夹结构,代码如下
import requests
from requests_ntlm import HttpNtlmAuth
headers = {'accept': 'application/json;odata=verbose'}
r = requests.post("https://xyz.sharepoint.com/_api/contextinfo", auth=HttpNtlmAuth('abc@xyz.com', 'pass123'), headers=headers)
print (r.status_code)
FormDigestValue = r.json()['d']['GetContextWebInformation']['FormDigestValue']
print (FormDigestValue)
file upload
POSTheaders = {'Accept':'application/json; odata=verbose','Content-Type':'application/json;
odata=verbose','X-RequestDigest':FormDigestValue, 'binaryStringRequestBody':'true'}
posturl = "https://xyz.sharepoint.com/_api/web/GetFolderByServerRelativeUrl('/sites/fol1/fol2')/files/add(url='pro\\sprints\\Sprint3_Test_Report.xlsx', overwrite='true')"
excelfile = {'file': ('pro\\sprints\\Sprint3_Test_Report.xlsx', open('pro\\sprints\\Sprint3_Test_Report.xlsx', 'rb'), 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')}
auth=HttpNtlmAuth('abc@xyz.com', 'pass123')
p = requests.post(posturl, headers=POSTheaders, files = excelfile, auth = auth)
print (p.status_code)
print (p.content)
它向我抛出 JSONDecodeError 额外数据:第 1 行第 5 列(字符 4)
我哪里错了? 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.