function DropBox-FileDelete {
Param (
[Parameter(Mandatory=$true)]
[string]$SourceFilePath
)
$DropBoxAccessToken = TOKEN HERE
$testFile = $SourceFilePath
$TargetFilePath="/$testFile"
$arg = '{"path": "' + $TargetFilePath + '"}'
$authorization = "Bearer " + $DropBoxAccessToken
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", $authorization)
$headers.Add("Content-Type", 'application/json')
try {
$result = Invoke-RestMethod -Uri https://api.dropboxapi.com/2/files/delete_v2 -Method Post -Headers $headers -Body $arg
}
catch {
$result = $_.Exception.Response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($result)
$reader.BaseStream.Position = 0
$reader.DiscardBufferedData()
$responseBody = $reader.ReadToEnd();
}
Write-Output $responseBody
}
DropBox-FileDelete "/Applicazioni/Costumer Manager Files/Ore.txt"
Hello. I just started using the API and I ran into this issue:
I can upload files, I can download files but I cannot delete them.
What am I missing here?
It seems a path problem, but to me the path is fine.
If the path was wrong, then I would not be able to upload or download, instead, I can download and upload just fine.
Response body:
{"error_summary": "path_lookup/malformed_path/", "error": {".tag": "path_lookup", "path_lookup": {".tag": "malformed_path"}}}