Cam*_*ker 2 sharepoint onedrive microsoft-teams microsoft-graph-api
我正在编写一个脚本,使用 Microsoft Graph API 1.0 将文件上传到文件夹。我正在尝试使运行脚本的用户可以复制并粘贴 sharepoint/onedrive 文件夹的路径。我当然也想使用该路径作为要上传文件的目的地。到目前为止,我找不到办法让它发挥作用。
路径示例:https ://example.sharepoint.com/sites/TheSite/Shared%20Documents/User
API参考:https://learn.microsoft.com/en-us/graph/api/resources/driveitem ?view=graph-rest-1.0
我尝试使用路径、部分路径以及主机名和路径的每个变体对 API 进行 GET 调用。我正在使用 Python Requests 库,身份验证不是问题。
收到的错误:
"error": {
"code": "itemNotFound",
"message": "The resource could not be found."
Run Code Online (Sandbox Code Playgroud)
和
"error": {
"code": "invalidRequest",
"message": "Invalid hostname for this tenancy",
Run Code Online (Sandbox Code Playgroud)
当我们使用存储路径的时候。我们必须选择完整的调用路径。无论是Azure blob容器还是Sharepoint或Drive。
\n请参考以下链接上传数据
\nhttps://learn.microsoft.com/en-us/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http \n https://medium.com/@rahul.metangale/upload -a-file-to-sharepoint-using-azure-graph-api-9deacce57449
\n上传步骤:
\n1)生成令牌 - 使用租户、客户端 ID、客户端密钥
\n2)获取驱动器 ID\nGET https://graph.microsoft.com/v1.0/drives
\n3)上传小于4MB的文档:\nPUT https://graph.microsoft.com/v1.0/drives/{{drive-id}}/items/root:/{{file-name}}:/content \ nHeader:\n\xe2\x80\x9cAuthorization\xe2\x80\x9d : \xe2\x80\x9cBearer \nBody: 二进制(在 postman 中选择正文中的二进制选项)\n使用选择文件选项上传文件\n文件名: 是文件名以及扩展名示例:test.txt
\n4)上传大于4MB的文档\nGET: https://graph.microsoft.com/v1.0/drives/{{drive-id}}/items/root:/{{file-name}}:/createUploadSession \ nHeader:\n\xe2\x80\x9cAuthorization\xe2\x80\x9d : \xe2\x80\x9cBearer \n这将返回上传 url\n上传文档\nPUT \nHeader:\n\xe2\x80\x9cAuthorization\xe2\x80\ x9d : \xe2\x80\x9cBearer \n正文:二进制(在邮递员中选择正文中的二进制选项)\n4)上传大于 4MB 的文档:\n标题:\n\xe2\x80\x9cAuthorization\xe2\x80\x9d : \xe2 \x80\x9c承载者
\n| 归档时间: |
|
| 查看次数: |
9556 次 |
| 最近记录: |