<?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: files_list_folder encoding issue in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-list-folder-encoding-issue/m-p/437004#M23062</link>
    <description>&lt;P&gt;That was the problem... My token had a &lt;EM&gt;em dash&lt;/EM&gt; in it... Thank you!!!&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jul 2020 16:29:32 GMT</pubDate>
    <dc:creator>sparkie127</dc:creator>
    <dc:date>2020-07-13T16:29:32Z</dc:date>
    <item>
      <title>files_list_folder encoding issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-list-folder-encoding-issue/m-p/436700#M23051</link>
      <description>&lt;P&gt;I've tried to use the sample code provided in other discussions to no avail.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;#!/usr/bin/env python
import dropbox

dbx = dropbox.Dropbox("***TOKEN*GOES*HERE***")

myDir = dbx.files_list_folder("")
for item in myDir.entries:
&amp;nbsp; if isinstance(item, dropbox.files.FileMetadata):
&amp;nbsp; &amp;nbsp; name = item.name
&amp;nbsp; &amp;nbsp; fileID = item.id
&amp;nbsp; &amp;nbsp; fileHash = item.content_hash
&amp;nbsp; &amp;nbsp; print(name, fileID, fileHash)&lt;/PRE&gt;
&lt;P&gt;but I get:&lt;/P&gt;
&lt;PRE&gt;Traceback (most recent call last):
  File "dropbox_test.py", line 51, in &amp;lt;module&amp;gt;
    myDir = dbx.files_list_folder("")
  File "/usr/local/lib/python3.8/dist-packages/dropbox/base.py", line 2118, in files_list_folder
    r = self.request(
  File "/usr/local/lib/python3.8/dist-packages/dropbox/dropbox.py", line 311, in request
    res = self.request_json_string_with_retry(host,
  File "/usr/local/lib/python3.8/dist-packages/dropbox/dropbox.py", line 461, in request_json_string_with_retry
    return self.request_json_string(host,
  File "/usr/local/lib/python3.8/dist-packages/dropbox/dropbox.py", line 557, in request_json_string
    r = self._session.post(url,
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 581, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 387, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.8/http/client.py", line 1240, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1281, in _send_request
    self.putheader(hdr, value)
  File "/usr/lib/python3.8/http/client.py", line 1213, in putheader
    values[i] = one_value.encode('latin-1')
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2014' in position 46: ordinal not in range(256)&lt;/PRE&gt;
&lt;P&gt;I deleted everything in my dropbox account thinking maybe it was a bad folder name/encoding, but still getting this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I saw another issue related to this, from a while back, but I don't think they are related, unless this is a new issue. (&lt;A href="https://github.com/dropbox/dropbox-sdk-python/issues/71" target="_blank" rel="noopener"&gt;https://github.com/dropbox/dropbox-sdk-python/issues/71&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using:&lt;/P&gt;
&lt;P&gt;Python&amp;nbsp;3.8.2&lt;/P&gt;
&lt;P&gt;dropbox 10.2.0&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 06:26:27 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-list-folder-encoding-issue/m-p/436700#M23051</guid>
      <dc:creator>sparkie127</dc:creator>
      <dc:date>2020-07-13T06:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: files_list_folder encoding issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-list-folder-encoding-issue/m-p/436993#M23060</link>
      <description>&lt;P&gt;This code looks correct, and doesn't fail for me when I plug in my own access token.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at the stack trace, it appears to be failing when making the request, specifically when writing a particular header. The only header here that would be varying though is the Authorization header with your access token. Also, the character it's failing on seems to be &lt;A href="https://www.fileformat.info/info/unicode/char/2014/index.htm" target="_self"&gt;the unicode character for an em dash&lt;/A&gt;. So, it sounds like your access token string has unicode in it, when it should only contain ASCII. (Perhaps you opened or saved it in a text editor that automatically performed some conversion?)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To fix this, replace any non-ASCII characters in your access token with the correct ASCII character, such as the ASCII dash "-", or just get a new access token and use it as is.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 16:05:02 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-list-folder-encoding-issue/m-p/436993#M23060</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-07-13T16:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: files_list_folder encoding issue</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-list-folder-encoding-issue/m-p/437004#M23062</link>
      <description>&lt;P&gt;That was the problem... My token had a &lt;EM&gt;em dash&lt;/EM&gt; in it... Thank you!!!&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 16:29:32 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/files-list-folder-encoding-issue/m-p/437004#M23062</guid>
      <dc:creator>sparkie127</dc:creator>
      <dc:date>2020-07-13T16:29:32Z</dc:date>
    </item>
  </channel>
</rss>

