来自 Dropboxfile_put 的文档 https://www.dropbox.com/developers/core/docs#files_put:
网址结构
https://api-content.dropbox.com/1/files_put/<root>/<path>?param=val
root相对于指定路径的根。有效值为sandbox
and dropbox.
path您要检索的文件的路径。
错误消息中的关键信息是请求中创建的 URI 的路径部分。错误消息中的相关行:
error making request to /1/files_put/sandboxsandbox/helloworld.txt
与文档中的 URL 结构相比,<root>
你用过sandboxsandbox
,但文档只说sandbox
and dropbox
是有效值。
JSON响应体中的错误也有类似的线索:
error=Expected 'root' to be 'dropbox', 'sandbox', or 'auto', got u'sandboxsandbox'
没有必要参考 API 文档,因为错误消息说明了这一点sandboxsandbox
不在有效值列表中root.
虽然不太明显,但与 URL 结构和文档相比,JSON 中的这一点给出了提示:
destinationPath=sandbox/helloworld.txt
经过一小步的飞跃之后目的地路径对应于path在 API 文档中并阅读root是“相对于指定路径的根”,您可以推测该路径不应包含根。是否应该是/helloworld.txt
or helloworld.txt
通过查看 URL 结构可以推断出/
之间<root>
and <path>
。使用比较这些扩展/helloworld.txt
and helloworld.txt
分别:
/1/files_put/<root>/<path>
/1/files_put/sandbox/<path>
/1/files_put/sandbox//helloworld.txt
/1/files_put/<root>/<path>
/1/files_put/sandbox/<path>
/1/files_put/sandbox/helloworld.txt
应该清楚哪个值path是正确的。