<?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: Delete a Folder programmatically in Discuss Dropbox Developer &amp; API</title>
    <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Delete-a-Folder-programmatically/m-p/715085#M3651</link>
    <description>&lt;P&gt;The code you shared calls &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata" target="_blank"&gt;/2/files/get_metadata&lt;/A&gt;, which retrieves metadata for a file or folder, but if you want to delete something, you should instead call &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-delete" target="_blank"&gt;/2/files/delete_v2&lt;/A&gt; (or &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-delete_batch" target="_blank"&gt;/2/files/delete_batch&lt;/A&gt; to delete multiple items). &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In any case, to debug a 400 error like this, print out the response body. It should contain a more useful error message.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Sep 2023 13:32:02 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2023-09-20T13:32:02Z</dc:date>
    <item>
      <title>Delete a Folder programmatically</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Delete-a-Folder-programmatically/m-p/714997#M3649</link>
      <description>&lt;P&gt;How can I write a programm to delete a folder in my dropbox. There are all permissions set. The accesstoken is ok. I'm able to create a folders in my code.&lt;/P&gt;&lt;P&gt;Unfortunately deleting a folder results in a 'bad request'. My folder structure is&lt;/P&gt;&lt;P&gt;Main/&lt;/P&gt;&lt;P&gt;....2023/&lt;/P&gt;&lt;P&gt;....2024/&lt;/P&gt;&lt;P&gt;Here is the code segment:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using (HttpClient httpClient = new HttpClient())
{

httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

HttpResponseMessage response = await httpClient.PostAsync("https://api.dropboxapi.com/2/files/get_metadata",
new StringContent($"{{\"path\": \"{filePath}\"}}"));

if (response.IsSuccessStatusCode)
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The variable response contains:&lt;/P&gt;&lt;P&gt;StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:&lt;BR /&gt;{&lt;BR /&gt;Content-Security-Policy: sandbox allow-forms allow-scripts&lt;BR /&gt;X-Content-Type-Options: nosniff&lt;BR /&gt;Accept-Encoding: identity,gzip&lt;BR /&gt;Vary: Accept-Encoding&lt;BR /&gt;X-Dropbox-Response-Origin: far_remote&lt;BR /&gt;X-Dropbox-Request-Id: 75a037a2e8b24097b5188d266d6b9b71&lt;BR /&gt;Cache-Control: no-cache&lt;BR /&gt;Date: Wed, 20 Sep 2023 10:11:08 GMT&lt;BR /&gt;Server: envoy&lt;BR /&gt;Content-Length: 226&lt;BR /&gt;Content-Type: text/plain; charset=utf-8&lt;BR /&gt;}}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you can help me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;best regards&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2023 10:29:25 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Delete-a-Folder-programmatically/m-p/714997#M3649</guid>
      <dc:creator>notstrom</dc:creator>
      <dc:date>2023-09-20T10:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: Delete a Folder programmatically</title>
      <link>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Delete-a-Folder-programmatically/m-p/715085#M3651</link>
      <description>&lt;P&gt;The code you shared calls &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata" target="_blank"&gt;/2/files/get_metadata&lt;/A&gt;, which retrieves metadata for a file or folder, but if you want to delete something, you should instead call &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-delete" target="_blank"&gt;/2/files/delete_v2&lt;/A&gt; (or &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-delete_batch" target="_blank"&gt;/2/files/delete_batch&lt;/A&gt; to delete multiple items). &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In any case, to debug a 400 error like this, print out the response body. It should contain a more useful error message.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2023 13:32:02 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Delete-a-Folder-programmatically/m-p/715085#M3651</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2023-09-20T13:32:02Z</dc:date>
    </item>
  </channel>
</rss>

