dropbox.exceptions.ApiError错误: ... CreateFileRequestError('验证错误',无)

2024-06-05 23:13:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我想通过python中的dropbox API获取图像的URL并将其保存到变量中。我遵循这个guide但是我得到了标题中显示的错误。你知道吗

我搜索了函数dbx.file_requests_create,可能是标题或目的地出错了。标题是否应该是某个现有的来源?因为我自己设定的。你知道吗

import dropbox

dbx = dropbox.Dropbox('Y2_M...aVP')
req = dbx.file_requests_create(title='Images', destination='/C:/Users/Dropbox/Apps/myProject/image.jpg')
print req.url
print req.id

编辑:我找到了这个链接FileRequestError。上面写着:

There was an error validating the request. For example, the title was invalid, or there were disallowed characters in the destination path.

EDIT-2[SOLVED]:多亏了Aran Fey和Greg的评论,我用req = dbx.file_requests_create(title='Images', destination='/C:/Users/Dropbox/Apps/myProject/image.jpg')替换了req = dbx.file_requests_create(title='Images', destination='/C:/Users/Dropbox/Apps/myProject/image.jpg')解决了这个问题

req = dbx.sharing_create_shared_link_with_settings('/image.jpg', settings=None)

另外,对于在共享图像时无法获取图像的用户,只需将链接的最后一个字符从0更改为1,如thisthis所述。 您可以在newURL = req.url[:-1] + "1"末尾添加这一行来解决问题。你知道吗


Tags: 图像image标题titlecreaterequestsdestinationreq