无法使用Dropbox Business团队令牌删除文件

时间:2018-09-17 13:28:07

标签: dropbox-api

以下代码应该起作用,不是吗?

import requests
import json

url = "https://api.dropboxapi.com/2/files/delete_v2"

headers = {
    "Authorization": "Bearer <access-token>",
    "Content-Type": "application/json",
    "Dropbox-Api-Select-Admin": 
    "dbmid:AADnRVGZHenLtFbLVdHDkqEJg3Dou4hWF4g"
}

data = {"path": "id:Kd_cXYig9pAAAAAAAAAARQ"}

print(requests.post(url, headers=headers, data=json.dumps(data)).content)

返回:

{"error_summary": "path_lookup/not_found/", "error": {".tag": "path_lookup", "path_lookup": {".tag": "not_found"}}}

尝试使用Dropbox-Api-Select-User并执行delete(v1)和永久删除,均因相同错误而失败。

仅供参考,下载成功。 (仅适用于Select-Admin,但有效)。

1 个答案:

答案 0 :(得分:0)

谢谢格雷格。 添加了“ Dropbox-Api-Path-Root”标头和parent_shared_folder_id,并且api调用成功了!

headers = {
"Authorization": "Bearer f7I8uYSFpxAAAAAAAAAFSs-VIz17DnoqmEYXp0MeitxIzXBCYCT4v0Bb4N4_cbxK",
"Content-Type": "application/json",
"Dropbox-Api-Path-Root": "{\".tag\": \"namespace_id\", \"namespace_id\": \"2857852064\"}",
"Dropbox-Api-Select-Admin": "dbmid:AADnRVGZHenLtFbLVdHDkqEJg3Dou4hWF4g"
}