0
votes

I am trying to make a c++ application that uses Dropbox. When I am trying to create a new folder I take the following error: {"error": "Not Found"} and "HTTP/1.1 404 Not Found".

I have followed the instruction of Dropbox's REST Api, so I have used the POST method. (I am not sure if I can use PUT, instead).

Here is my code:

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);
    }

}

Please, does anyone have an idea about what am I doing wrong?

1

1 Answers

0
votes

Looking at the documentation I belive you want to leave sandbox/test_folder off of the url and use root=sandbox & path=test_folder as form values.

Here is an example of submitting form parameters: http://curl.haxx.se/libcurl/c/postit2.html

EDIT: I found another example, here: http://cgeers.com/2012/02/19/dropbox-rest-api-part-3-create-delete-and-move-folders/ which seems to show the parameters being added to the url's query string rather than as form values. The doc page isn't clear. It just shows them as parameters but doesn't specify which kind.