我正在尝试使用 Dropbox API 从 Dropbox 下载文件。我使用下面的代码
axios.post('https://content.dropboxapi.com/2/files/download', {
method: 'POST',
headers: {
Authorization: 'Bearer ${MY token}',
'Dropbox-API-Arg': { path: '/Thillai Maharajan.jpg' }
}
})
.then(function (response) {
console.log("RESPONSE: ",response.data);
})
.catch(function (error) {
console.log("ERROR RES",error);
});
但它说数据:'调用 API 函数“文件/下载”时出错:必须提供 HTTP 标头“授权”或 URL 参数“授权”。'
有人可以帮忙吗?
您可以在 https://www.dropbox.com/developers/documentation/http/documentation#files-download
参考 Dropbox API 文档答案 0 :(得分:0)
我刚刚得到了答案。我必须使用 Dropbox-API-Arg
将 JSON.stringify()
参数字符串化。因为标头参数不能是 JSON。我改变了它,它奏效了。
'Dropbox-API-Arg' : JSON.stringify({"path":"/Thillai Maharajan.jpg"})