<?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 how download file with oauth2 in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/how-download-file-with-oauth2/m-p/151445#M5014</link>
    <description>&lt;P&gt;Hi all, I'm switching my Dropbox app from oauth1 to oauth2. I've an issue when I try to download a file.&lt;/P&gt;
&lt;P&gt;I use this code:&lt;/P&gt;
&lt;P&gt;var r = Call("&lt;A href="https://content.dropboxapi.com/2/files/download" rel="nofollow noreferrer" target="_blank"&gt;https://content.dropboxapi.com/2/files/download&lt;/A&gt;", access_token, "{\"path\":\"" + metaPath + "\"}");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;private string Call(string endpoint, string access_token, string json) {&lt;BR /&gt; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(endpoint);&lt;BR /&gt; request.ContentType = "application/json";&lt;BR /&gt; request.Headers.Add("Authorization", "Bearer " + access_token);&lt;BR /&gt; request.Method = "POST";&lt;BR /&gt; Stream requestStream = request.GetRequestStream();&lt;BR /&gt; requestStream.Write(Encoding.UTF8.GetBytes(json), 0, json.Length);&lt;BR /&gt; requestStream.Close();&lt;BR /&gt; HttpWebResponse response = (HttpWebResponse)request.GetResponse();&lt;BR /&gt; Stream dataStream = response.GetResponseStream();&lt;BR /&gt; StreamReader reader = new StreamReader(dataStream);&lt;BR /&gt; string txtResponse = reader.ReadToEnd();&lt;BR /&gt; return txtResponse;&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "Call" function works well&amp;nbsp;whit *list_folder* endpoint. But I get a 400 http error (invalid request) with *download* endopint. Any tips? It's the right way?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2019 09:39:37 GMT</pubDate>
    <dc:creator>Daniele F.1</dc:creator>
    <dc:date>2019-05-29T09:39:37Z</dc:date>
    <item>
      <title>how download file with oauth2</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/how-download-file-with-oauth2/m-p/151445#M5014</link>
      <description>&lt;P&gt;Hi all, I'm switching my Dropbox app from oauth1 to oauth2. I've an issue when I try to download a file.&lt;/P&gt;
&lt;P&gt;I use this code:&lt;/P&gt;
&lt;P&gt;var r = Call("&lt;A href="https://content.dropboxapi.com/2/files/download" rel="nofollow noreferrer" target="_blank"&gt;https://content.dropboxapi.com/2/files/download&lt;/A&gt;", access_token, "{\"path\":\"" + metaPath + "\"}");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;private string Call(string endpoint, string access_token, string json) {&lt;BR /&gt; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(endpoint);&lt;BR /&gt; request.ContentType = "application/json";&lt;BR /&gt; request.Headers.Add("Authorization", "Bearer " + access_token);&lt;BR /&gt; request.Method = "POST";&lt;BR /&gt; Stream requestStream = request.GetRequestStream();&lt;BR /&gt; requestStream.Write(Encoding.UTF8.GetBytes(json), 0, json.Length);&lt;BR /&gt; requestStream.Close();&lt;BR /&gt; HttpWebResponse response = (HttpWebResponse)request.GetResponse();&lt;BR /&gt; Stream dataStream = response.GetResponseStream();&lt;BR /&gt; StreamReader reader = new StreamReader(dataStream);&lt;BR /&gt; string txtResponse = reader.ReadToEnd();&lt;BR /&gt; return txtResponse;&lt;BR /&gt; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "Call" function works well&amp;nbsp;whit *list_folder* endpoint. But I get a 400 http error (invalid request) with *download* endopint. Any tips? It's the right way?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:39:37 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/how-download-file-with-oauth2/m-p/151445#M5014</guid>
      <dc:creator>Daniele F.1</dc:creator>
      <dc:date>2019-05-29T09:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: how download file with oauth2</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/how-download-file-with-oauth2/m-p/151446#M5015</link>
      <description>&lt;P&gt;Sorry for the confusion here... we're still missing&amp;nbsp;some overview documentation that may have made this clearer.&lt;/P&gt;
&lt;P&gt;For "content-style" endpoints like upload and download,&amp;nbsp;the JSON is passed in the "Dropbox-Api-Arg" header, not in the body of the request. Take a look at the example curl requests in the documentation to get&amp;nbsp;the hang of this.&lt;/P&gt;
&lt;P&gt;So you'll want something like this (completely untested):&lt;/P&gt;
&lt;PRE&gt;private string CallContent(string endpoint, string access_token, string json) {&lt;BR /&gt;    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(endpoint);&lt;BR /&gt;    request.Headers.Add("Authorization", "Bearer " + access_token);&lt;BR /&gt;    request.Headers.Add("Dropbox-API-Arg", json);&lt;BR /&gt;    request.Method = "POST";&lt;BR /&gt;    HttpWebResponse response = (HttpWebResponse)request.GetResponse();&lt;BR /&gt;    Stream dataStream = response.GetResponseStream();&lt;BR /&gt;    StreamReader reader = new StreamReader(dataStream);&lt;BR /&gt;    string txtResponse = reader.ReadToEnd();&lt;BR /&gt;    return txtResponse;&lt;BR /&gt;}&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Oct 2015 22:37:52 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/how-download-file-with-oauth2/m-p/151446#M5015</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2015-10-02T22:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: how download file with oauth2</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/how-download-file-with-oauth2/m-p/151447#M5016</link>
      <description>&lt;P&gt;As another tip, I'd say you should always read the body of the HTTP response when you get an error. The body of the&amp;nbsp;400 from the API&amp;nbsp;will generally tell you exactly what's wrong with the request.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2015 22:41:05 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/how-download-file-with-oauth2/m-p/151447#M5016</guid>
      <dc:creator>Steve M.</dc:creator>
      <dc:date>2015-10-02T22:41:05Z</dc:date>
    </item>
  </channel>
</rss>

