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}"
LOCAL loRest
LOCAL lnSuccess
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJsonResponse
LOCAL lcFrom_path
LOCAL lcTo_path
LOCAL lnAllow_shared_folder
LOCAL lnAutorename
LOCAL lnAllow_ownership_transfer
loRest = CreateObject('Chilkat_9_5_0.Rest')
* URL: https://api.dropboxapi.com/2/files/move_v2
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("api.dropboxapi.com",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
? loRest.LastErrorText
RELEASE loRest
CANCEL
ENDIF
* See the Online Tool for Generating JSON Creation Code
loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateString("from_path","/Homework/math/ghost_emoji.txt")
loJson.UpdateString("to_path","/Halloween/emojis/ghost.txt")
loJson.UpdateBool("allow_shared_folder",0)
loJson.UpdateBool("autorename",0)
loJson.UpdateBool("allow_ownership_transfer",0)
loRest.AddHeader("Authorization","Bearer DROPBOX-ACCESS-TOKEN")
loRest.AddHeader("Content-Type","application/json")
loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestSb("POST","/2/files/move_v2",loSbRequestBody,loSbResponseBody)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
CANCEL
ENDIF
lnRespStatusCode = loRest.ResponseStatusCode
IF (lnRespStatusCode >= 400) THEN
? "Response Status Code = " + STR(lnRespStatusCode)
? "Response Header:"
? loRest.ResponseHeader
? "Response Body:"
? loSbResponseBody.GetAsString()
RELEASE loRest
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
CANCEL
ENDIF
loJsonResponse = CreateObject('Chilkat_9_5_0.JsonObject')
loJsonResponse.LoadSb(loSbResponseBody)
* See the Online Tool for Generating JSON Parse Code
lcFrom_path = loJsonResponse.StringOf("from_path")
lcTo_path = loJsonResponse.StringOf("to_path")
lnAllow_shared_folder = loJsonResponse.BoolOf("allow_shared_folder")
lnAutorename = loJsonResponse.BoolOf("autorename")
lnAllow_ownership_transfer = loJsonResponse.BoolOf("allow_ownership_transfer")
RELEASE loRest
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJsonResponse
{
"from_path": "/Homework/math/ghost_emoji.txt",
"to_path": "/Halloween/emojis/ghost.txt",
"allow_shared_folder": false,
"autorename": false,
"allow_ownership_transfer": false
}