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}"
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
CkRest rest = new CkRest();
boolean success;
// URL: https://api.dropboxapi.com/2/files/move_v2
boolean bTls = true;
int port = 443;
boolean bAutoReconnect = true;
success = rest.Connect("api.dropboxapi.com",port,bTls,bAutoReconnect);
if (success != true) {
System.out.println("ConnectFailReason: " + rest.get_ConnectFailReason());
System.out.println(rest.lastErrorText());
return;
}
// See the Online Tool for Generating JSON Creation Code
CkJsonObject json = new CkJsonObject();
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 = new CkStringBuilder();
json.EmitSb(sbRequestBody);
CkStringBuilder sbResponseBody = new CkStringBuilder();
success = rest.FullRequestSb("POST","/2/files/move_v2",sbRequestBody,sbResponseBody);
if (success != true) {
System.out.println(rest.lastErrorText());
return;
}
int respStatusCode = rest.get_ResponseStatusCode();
if (respStatusCode >= 400) {
System.out.println("Response Status Code = " + respStatusCode);
System.out.println("Response Header:");
System.out.println(rest.responseHeader());
System.out.println("Response Body:");
System.out.println(sbResponseBody.getAsString());
return;
}
CkJsonObject jsonResponse = new CkJsonObject();
jsonResponse.LoadSb(sbResponseBody);
// See the Online Tool for Generating JSON Parse Code
String from_path = jsonResponse.stringOf("from_path");
String to_path = jsonResponse.stringOf("to_path");
boolean allow_shared_folder = jsonResponse.BoolOf("allow_shared_folder");
boolean autorename = jsonResponse.BoolOf("autorename");
boolean 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
}