通过libcurl在dropbox上创建文件夹时出错
error when creating folder on dropbox via libcurl
我正在尝试制作一个使用Dropbox的c++应用程序。当我试图创建一个新文件夹时,我会出现以下错误:{"error":"Not Found"}和"HTTP/1.1 404 Not Found(HTTP/1.1 404Not Found)"。
我遵循了Dropbox的RESTApi的说明,所以我使用了POST方法。(我不确定是否可以使用PUT)。
这是我的代码:
void createDirectory(const char *new_Directory_Path)
{string create_Directory_Url="https://api.dropbox.com/1/fileops/create_folder/sandbox/test_folder";
CURL* curl = curl_easy_init();
if(!curl)
{
CURLcode res;
struct curl_slist *headers = NULL;
string my_header = "Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT",
oauth_consumer_key=""
+ m_consumer_key + "", oauth_token="" + m_accessKey + "", oauth_signature=""
+ m_consumer_secret + "&" + m_accessSecret + """;
headers = curl_slist_append(headers, my_header.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
curl_easy_setopt(curl, CURLOPT_URL, create_Directory_Url.c_str());
res = curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
}
拜托,有人知道我做错了什么吗?
查看文档,我认为您希望将sandbox/test_folder从url中删除,并使用root=sandbox&path=test_folder作为表单值。
以下是提交表单参数的示例:http://curl.haxx.se/libcurl/c/postit2.html
编辑:我在这里找到了另一个例子:https://github.com/geersch/DropboxRESTApi/blob/master/src/part-3/README.md它似乎显示了添加到url的查询字符串中的参数,而不是表单值。文档页面不清晰。它只是将它们显示为参数,但没有指定哪种类型。
相关文章:
- 如何将更多文件夹添加到c++include路径
- GetShortPathName在网络驱动器上使用中文文件夹时失败
- VS2017,C++包含目录与附加包含目录,子文件夹包含失败-但为什么
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 如何在文档文件夹中创建目录
- "assimp/config.h"找不到,但它在文件夹中
- C++入门 5 版:类消息和文件夹
- 在 C/C++ 中打开驻留在 "/sys/" 下的文件时出错
- 我可以在 Arduino 的库文件夹之外安装库吗?
- 如何按文件扩展名引用文件夹中的文件
- 在QTreeView中仅显示共享驱动器和文件夹
- 加载与引用 .NET DLL 位于同一文件夹中的引用的 .NET DLL 时"Not found"异常
- 介子复制/安装头文件到输出目录并保持文件夹结构
- vcruntime.h 从 Windows 包含文件夹中丢失?
- 在文件夹迭代上实现 RAII
- 使用 Powershell 命令将 cpp 文件的文件夹编译为 GNU 的 g++
- 使文件夹中的所有文件可供所有项目(子目录)访问
- 使用 Boost 列出文件夹中的文件时出错
- 通过libcurl在dropbox上创建文件夹时出错
- 读取子文件夹中的许多文件时出错