Move a file or folder to a different location in the user's Dropbox. If the source path is a folder all its contents will be moved.
curl -X POST https://api.dropboxapi.com/2/files/move_v2 \
--header "Authorization: Bearer DROPBOX-ACCESS-TOKEN" \
--header "Content-Type: application/json" \
--data "{\"from_path\": \"/Homework/math/ghost_emoji.txt\",\"to_path\": \"/Halloween/emojis/ghost.txt\",\"allow_shared_folder\": false,\"autorename\": false,\"allow_ownership_transfer\": false}"
#include <CkRest.h>
#include <CkJsonObject.h>
#include <CkStringBuilder.h>
void ChilkatSample(void)
{
CkRest rest;
bool success;
// URL: https://api.dropboxapi.com/2/files/move_v2
bool bTls = true;
int port = 443;
bool bAutoReconnect = true;
success = rest.Connect("api.dropboxapi.com",port,bTls,bAutoReconnect);
if (success != true) {
std::cout << "ConnectFailReason: " << rest.get_ConnectFailReason() << "\r\n";
std::cout << rest.lastErrorText() << "\r\n";
return;
}
// See the Online Tool for Generating JSON Creation Code
CkJsonObject json;
json.UpdateString("from_path","/Homework/math/ghost_emoji.txt");
json.UpdateString("to_path","/Halloween/emojis/ghost.txt");
json.UpdateBool("allow_shared_folder",false);
json.UpdateBool("autorename",false);
json.UpdateBool("allow_ownership_transfer",false);
rest.AddHeader("Authorization","Bearer DROPBOX-ACCESS-TOKEN");
rest.AddHeader("Content-Type","application/json");
CkStringBuilder sbRequestBody;
json.EmitSb(sbRequestBody);
CkStringBuilder sbResponseBody;
success = rest.FullRequestSb("POST","/2/files/move_v2",sbRequestBody,sbResponseBody);
if (success != true) {
std::cout << rest.lastErrorText() << "\r\n";
return;
}
int respStatusCode = rest.get_ResponseStatusCode();
if (respStatusCode >= 400) {
std::cout << "Response Status Code = " << respStatusCode << "\r\n";
std::cout << "Response Header:" << "\r\n";
std::cout << rest.responseHeader() << "\r\n";
std::cout << "Response Body:" << "\r\n";
std::cout << sbResponseBody.getAsString() << "\r\n";
return;
}
CkJsonObject jsonResponse;
jsonResponse.LoadSb(sbResponseBody);
// See the Online Tool for Generating JSON Parse Code
const char *from_path = jsonResponse.stringOf("from_path");
const char *to_path = jsonResponse.stringOf("to_path");
bool allow_shared_folder = jsonResponse.BoolOf("allow_shared_folder");
bool autorename = jsonResponse.BoolOf("autorename");
bool allow_ownership_transfer = jsonResponse.BoolOf("allow_ownership_transfer");
}
{
"from_path": "/Homework/math/ghost_emoji.txt",
"to_path": "/Halloween/emojis/ghost.txt",
"allow_shared_folder": false,
"autorename": false,
"allow_ownership_transfer": false
}