<?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: Downloading a zip file using Api doesnt work in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Downloading-a-zip-file-using-Api-doesnt-work/m-p/699355#M31222</link>
    <description>&lt;P&gt;The &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-download_zip" target="_blank"&gt;/2/files/download_zip endpoint&lt;/A&gt; is only meant for downloading folders from Dropbox, not files. (Dropbox zips the folder into a zip file on the fly for that.) To download a file (whether the file is a .zip file or not), you would use the &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-download" target="_blank"&gt;/2/files/download endpoint&lt;/A&gt; instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, it looks like your `path` value might be malformed regardless, at least based on the code you shared here, since you're building it as `"/$dropboxFolderPath/$latestFilename"`, and you're setting `dropboxFolderPath` as `dropboxFolderPath=""`, so `"/$dropboxFolderPath/$latestFilename"`, would contain an empty path component as the first path component.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In any case, you should also check the status code of the HTTPS response to see if the call succeeded or failed, and only save the data if the call succeeded. If it failed, you might just be saving the error message instead of the file data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And for debugging issues, you can use the "-v" flag on curl to enable verbose output.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jul 2023 18:23:31 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2023-07-17T18:23:31Z</dc:date>
    <item>
      <title>Downloading a zip file using Api doesnt work</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Downloading-a-zip-file-using-Api-doesnt-work/m-p/699323#M31221</link>
      <description>&lt;P&gt;Hello Team ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a "App folder" created and I try to list all the files inside the folder . From the response received , I grep for a particular zip file and download the zip file using "/2/files/download_zip" endpoint . It does download the zip file but when I try to unzip it using "unzip &amp;lt;filename&amp;gt;" , it doesnt unzip , the file is corrupted . When I download the zip file manually and try to unzip it , it works fine . So the issue is not with the file . Kindly help . Following is the error :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;note: Assessor-4.31-cli-linux.zip may be a plain executable, not an archive&lt;BR /&gt;unzip: cannot find zipfile directory in one of Assessor-4.31-cli-linux.zip or&lt;BR /&gt;Assessor-4.31-cli-linux.zip.zip, and cannot find Assessor-4.31-cli-linux.zip.ZIP, period.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the code I'm using : I also try to compare all the files and retrieve the latest version for download&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;dropboxFolderPath=""&lt;BR /&gt;localDestination="/usr/orabkup/CISCAT"&lt;/P&gt;
&lt;P&gt;apiUrl="&lt;A href="https://api.dropboxapi.com/2/files/list_folder" target="_blank" rel="noopener"&gt;https://api.dropboxapi.com/2/files/list_folder&lt;/A&gt;"&lt;BR /&gt;# Set the headers for the API request&lt;BR /&gt;headers=(&lt;BR /&gt;"Authorization: Bearer $dropboxToken"&lt;BR /&gt;"Content-Type: application/json"&lt;BR /&gt;)&lt;BR /&gt;# Specify the folder path in the Dropbox API request body&lt;BR /&gt;body="{\"path\": \"$dropboxFolderPath\", \"recursive\": true}"&lt;BR /&gt;# Make the API request to list the files in the folder&lt;BR /&gt;response=$(curl -X POST -H "${headers[0]}" -H "${headers[1]}" --data "$body" "$apiUrl")&lt;BR /&gt;echo $response&lt;/P&gt;
&lt;P&gt;# Check if the API request was successful&lt;BR /&gt;if [[ $response ]]; then&lt;BR /&gt;# Filter the files based on the pattern "*Assessor*linux*.zip"&lt;/P&gt;
&lt;P&gt;files=$(echo "$response" | grep -o '"name": "[^"]*"' | sed 's/"name": "//;s/"$//' | grep "Assessor.*linux.*\.zip")&lt;BR /&gt;# echo $files&lt;BR /&gt;latestVersion=""&lt;BR /&gt;latestFilename=""&lt;BR /&gt;for filename in $files; do&lt;BR /&gt;version=$(echo "$filename" | grep -oP '(?&amp;lt;=-)[\d\.]+(?=[-\.])')&lt;BR /&gt;if [[ -z $latestVersion ]]; then&lt;BR /&gt;latestVersion=$version&lt;BR /&gt;latestFilename=$filename&lt;BR /&gt;elif [[ $(printf "%s\n%s" "$version" "$latestVersion" | sort -V | tail -n 1) == $version ]]; then&lt;/P&gt;
&lt;P&gt;latestVersion=$version&lt;BR /&gt;latestFilename=$filename&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;#echo $latestFilename&lt;BR /&gt;if [[ -n $latestFilename ]]; then&lt;BR /&gt;# Download the file with the latest version&lt;BR /&gt;localPath="$localDestination/$latestFilename"&lt;BR /&gt;downloadUrl="&lt;A href="https://content.dropboxapi.com/2/files/download_zip" target="_blank" rel="noopener"&gt;https://content.dropboxapi.com/2/files/download_zip&lt;/A&gt;"&lt;BR /&gt;downloadHeaders=(&lt;BR /&gt;"Authorization: Bearer $dropboxToken"&lt;BR /&gt;"Dropbox-API-Arg: {\"path\": \"/$dropboxFolderPath/$latestFilename\"}"&lt;BR /&gt;)&lt;BR /&gt;curl -s -X POST -H "${downloadHeaders[0]}" -H "${downloadHeaders[1]}" -o "$localPath" "$downloadUrl"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 07:51:02 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Downloading-a-zip-file-using-Api-doesnt-work/m-p/699323#M31221</guid>
      <dc:creator>nive</dc:creator>
      <dc:date>2023-07-19T07:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Downloading a zip file using Api doesnt work</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Downloading-a-zip-file-using-Api-doesnt-work/m-p/699355#M31222</link>
      <description>&lt;P&gt;The &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-download_zip" target="_blank"&gt;/2/files/download_zip endpoint&lt;/A&gt; is only meant for downloading folders from Dropbox, not files. (Dropbox zips the folder into a zip file on the fly for that.) To download a file (whether the file is a .zip file or not), you would use the &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#files-download" target="_blank"&gt;/2/files/download endpoint&lt;/A&gt; instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, it looks like your `path` value might be malformed regardless, at least based on the code you shared here, since you're building it as `"/$dropboxFolderPath/$latestFilename"`, and you're setting `dropboxFolderPath` as `dropboxFolderPath=""`, so `"/$dropboxFolderPath/$latestFilename"`, would contain an empty path component as the first path component.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In any case, you should also check the status code of the HTTPS response to see if the call succeeded or failed, and only save the data if the call succeeded. If it failed, you might just be saving the error message instead of the file data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And for debugging issues, you can use the "-v" flag on curl to enable verbose output.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2023 18:23:31 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Downloading-a-zip-file-using-Api-doesnt-work/m-p/699355#M31222</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2023-07-17T18:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: Downloading a zip file using Api doesnt work</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Downloading-a-zip-file-using-Api-doesnt-work/m-p/699357#M31223</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1723539"&gt;@nive&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;... It does download the zip file ...&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/1723539"&gt;@nive&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Wow...&lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@D6F1E7339C4A1D356873D19B1E420FB0/emoticons/1f62f.png" alt=":hushed_face:" title=":hushed_face:" /&gt; Really? That would be really surprising. &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;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1723539"&gt;@nive&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;... I grep for a particular zip file and download the zip file using "/2/files/download_zip" endpoint . ...&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;If you take a look on &lt;A title="Download a folder from the user's Dropbox, as a zip file" href="https://www.dropbox.com/developers/documentation/http/documentation#files-download_zip" target="_blank" rel="noopener"&gt;/2/files/download_zip&lt;/A&gt;'s documentation:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;Download a folder from the user's Dropbox, as a zip file. The folder must be less than 20 GB in size and any single file within must be less than 4 GB in size. The resulting zip must have fewer than 10,000 total file and folder entries, including the top level folder. The input &lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;U&gt;cannot be a single file&lt;/U&gt;&lt;/EM&gt;&lt;/FONT&gt;. ...&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Why do you decided that you need to use exactly this API access point? Let's recall the zip file is a... file! It's NOT a folder. &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@FBF7D2AB59A0D6E861EBF6A36F93B7E2/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;&lt;P&gt;By the way, when you say that particular thing is done ("It does download the zip file" in particular), better check what has been done actually and is there some error in meantime! Actually you don't check for error at all and that's where you confusion comes from. &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; You got - "error_summary": "path/not_folder/.." for sure. Does this text look like a zip file content? &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;/P&gt;&lt;P&gt;Hope this clarifies matter and gives direction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: By default curl doesn't report server side errors as a returned status. To make curl respond with corresponding status (that you can check) use -f flag.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2023 18:41:13 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Downloading-a-zip-file-using-Api-doesnt-work/m-p/699357#M31223</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2023-07-17T18:41:13Z</dc:date>
    </item>
  </channel>
</rss>

