<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can't delete files with powershell in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-delete-files-with-powershell/m-p/615161#M28393</link>
    <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1564060"&gt;@lucaortis&lt;/a&gt; As Здравко pointed out, you have a double leading slash, which is not a valid path format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Specifically, you're supplying the path "/Applicazioni/Costumer Manager Files/Ore.txt", but then are adding an extra leading slash when you format it with your code:&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-markup"&gt;&lt;CODE&gt;$TargetFilePath="/$testFile"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Aug 2022 15:28:27 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2022-08-10T15:28:27Z</dc:date>
    <item>
      <title>Can't delete files with powershell</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-delete-files-with-powershell/m-p/615087#M28390</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;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"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello. I just started using the API and I ran into this issue:&amp;nbsp;&lt;BR /&gt;I can upload files, I can download files but I cannot delete them.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;What am I missing here?&amp;nbsp;&lt;BR /&gt;It seems a path problem, but to me the path is fine.&amp;nbsp;&lt;BR /&gt;If the path was wrong, then I would not be able to upload or download, instead, I can download and upload just fine.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Response body:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{"error_summary": "path_lookup/malformed_path/", "error": {".tag": "path_lookup", "path_lookup": {".tag": "malformed_path"}}}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 10:59:48 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-delete-files-with-powershell/m-p/615087#M28390</guid>
      <dc:creator>lucaortis</dc:creator>
      <dc:date>2022-08-10T10:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Can't delete files with powershell</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-delete-files-with-powershell/m-p/615136#M28391</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1564060"&gt;@lucaortis&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;...&lt;BR /&gt;It seems a path problem, but to me the path is fine.&amp;nbsp;&lt;BR /&gt;If the path was wrong, then I would not be able to upload or download, instead, I can download and upload just fine.&amp;nbsp;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1564060"&gt;@lucaortis&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You haven't posted the code responsible for upload and download. Are you using in the path there double leading slashes too? &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@9AD39CA637682E9616FBE31CDAF1B6C4/emoticons/1f914.png" alt=":thinking_face:" title=":thinking_face:" /&gt;&lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@D88F213CAFB196B6AB70612B08AD9D31/emoticons/1f601.png" alt=":beaming_face_with_smiling_eyes:" title=":beaming_face_with_smiling_eyes:" /&gt;&lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/P&gt;&lt;P&gt;Hope this gives direction.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 13:09:26 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-delete-files-with-powershell/m-p/615136#M28391</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2022-08-10T13:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: Can't delete files with powershell</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-delete-files-with-powershell/m-p/615161#M28393</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1564060"&gt;@lucaortis&lt;/a&gt; As Здравко pointed out, you have a double leading slash, which is not a valid path format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Specifically, you're supplying the path "/Applicazioni/Costumer Manager Files/Ore.txt", but then are adding an extra leading slash when you format it with your code:&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-markup"&gt;&lt;CODE&gt;$TargetFilePath="/$testFile"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 15:28:27 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-delete-files-with-powershell/m-p/615161#M28393</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2022-08-10T15:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Can't delete files with powershell</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-delete-files-with-powershell/m-p/615177#M28394</link>
      <description>&lt;P&gt;I found this very confusing but I managed to solve it like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; $testFile = Split-Path $SourceFilePath -leaf
 $TargetFilePath="/$testFile"
 $arg = '{"path": "' + $TargetFilePath + '"}'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know it works, but I'm really confused on how the path itself works.&amp;nbsp;&lt;BR /&gt;Upload and download code to format PATH are now the same as this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 18:32:20 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Can-t-delete-files-with-powershell/m-p/615177#M28394</guid>
      <dc:creator>lucaortis</dc:creator>
      <dc:date>2022-08-10T18:32:20Z</dc:date>
    </item>
  </channel>
</rss>

