Copy 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 copied.
curl -X POST https://api.dropboxapi.com/2/files/copy_v2 \
--header "Authorization: Bearer DROPBOX-ACCESS-TOKEN" \
--header "Content-Type: application/json" \
--data "{\"from_path\": \"/ocean/starfish.jpg\",\"to_path\": \"/ocean/starfish2.jpg\",\"allow_shared_folder\": false,\"autorename\": false,\"allow_ownership_transfer\": false}"
Dim rest As Chilkat.Rest
Set rest = Chilkat.NewRest
' URL: https://api.dropboxapi.com/2/files/copy_v2
bTls = True
port = 443
bAutoReconnect = True
success = rest.Connect("api.dropboxapi.com",port,bTls,bAutoReconnect)
If (success <> True) Then
Debug.Print "ConnectFailReason: "; rest.ConnectFailReason
Debug.Print rest.LastErrorText
Exit Sub
End If
' See the Online Tool for Generating JSON Creation Code
Dim json As Chilkat.JsonObject
Set json = Chilkat.NewJsonObject
success = json.UpdateString("from_path","/ocean/starfish.jpg")
success = json.UpdateString("to_path","/ocean/starfish2.jpg")
success = json.UpdateBool("allow_shared_folder",False)
success = json.UpdateBool("autorename",False)
success = json.UpdateBool("allow_ownership_transfer",False)
success = rest.AddHeader("Authorization","Bearer DROPBOX-ACCESS-TOKEN")
success = rest.AddHeader("Content-Type","application/json")
Dim sbRequestBody As Chilkat.StringBuilder
Set sbRequestBody = Chilkat.NewStringBuilder
success = json.EmitSb(sbRequestBody)
Dim sbResponseBody As Chilkat.StringBuilder
Set sbResponseBody = Chilkat.NewStringBuilder
success = rest.FullRequestSb("POST","/2/files/copy_v2",sbRequestBody,sbResponseBody)
If (success <> True) Then
Debug.Print rest.LastErrorText
Exit Sub
End If
respStatusCode = rest.ResponseStatusCode
If (respStatusCode >= 400) Then
Debug.Print "Response Status Code = "; respStatusCode
Debug.Print "Response Header:"
Debug.Print rest.ResponseHeader
Debug.Print "Response Body:"
Debug.Print sbResponseBody.GetAsString()
Exit Sub
End If
Dim jsonResponse As Chilkat.JsonObject
Set jsonResponse = Chilkat.NewJsonObject
success = jsonResponse.LoadSb(sbResponseBody)
' See the Online Tool for Generating JSON Parse Code
metadataTag = jsonResponse.StringOf("metadata."".tag""")
metadataName = jsonResponse.StringOf("metadata.name")
metadataPath_lower = jsonResponse.StringOf("metadata.path_lower")
metadataPath_display = jsonResponse.StringOf("metadata.path_display")
metadataId = jsonResponse.StringOf("metadata.id")
metadataClient_modified = jsonResponse.StringOf("metadata.client_modified")
metadataServer_modified = jsonResponse.StringOf("metadata.server_modified")
metadataRev = jsonResponse.StringOf("metadata.rev")
metadataSize = jsonResponse.IntOf("metadata.size")
metadataContent_hash = jsonResponse.StringOf("metadata.content_hash")
{
"metadata": {
".tag": "file",
"name": "starfish2.jpg",
"path_lower": "/ocean/starfish2.jpg",
"path_display": "/ocean/starfish2.jpg",
"id": "id:JSXYsxHo1hAAAAAAAAAADg",
"client_modified": "2018-10-22T22:38:18Z",
"server_modified": "2018-10-22T22:40:38Z",
"rev": "1c482db15f",
"size": 6229,
"content_hash": "9fa9d692d0762ee759c22dea993c7de0068f9ba2ca842e761a1636d3b0b3cbba"
}
}