我很确定我的代码从一月份起就没有改变过,但现在由于某种原因它不再工作了。它在2021年1月、2月和3月起作用
这是我以前用来完成任务的参考资料,我以前能够使它工作:https://docs.microsoft.com/en-us/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http
当我试图通过邮递员上传一些测试数据时,我得到了这个令人困惑的错误,因为根据手册,内容类型应该是text/plain,但它说实体只允许JSON
{
"error": {
"code": "BadRequest",
"message": "Entity only allows writes with a JSON Content-Type header.",
"innerError": {
"date": "2021-04-01T21:11:10",
"request-id": "5c371ff3-3be6-47fa-a754-0a43de10a52d",
"client-request-id": "5c371ff3-3be6-47fa-a754-0a43de10a52d"
}
}
}
下面是我从Postman为python生成的代码
import requests
url = "https://graph.microsoft.com/v1.0/sites/{sharepoint_company_site}/drives/{parent_drive}/items/:/test_auto_upload.txt:/content"
payload="test1,test2,test3\ntest1,test2,test3\ntest1,test2,test3\ntest1,test2,test3"
headers = {
'Content-Type': 'text/plain',
'SdkVersion': 'postman-graph/v1.0',
'Authorization': f'Bearer {access_token}'
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
我原以为实现中有一些更改,但在Microsoft graph API的更改日志中没有得到与文件上载相关的结果
我不知道该怎么做。任何帮助都将不胜感激
目前没有回答
相关问题 更多 >
编程相关推荐