Dropbox API v2 - trying to upload file with files_upload() - throws TypeError
<p>I have been trying to upload a simple file to dropbox using the files_upload() function in python3</p>

<p>Even trying out the code in the <a href="https://www.dropbox.com/developers/documentation/python#tutorial" rel="noreferrer">tutorial provided on Dropbox's site</a> I get an error and I don't understand why. What am I missing here?</p>

<p><strong>Here is my code:</strong></p>

<pre><code>import dropbox

dbx = dropbox.Dropbox("my_access_token")

data = "asd"

dbx.files_upload(data, '/file.txt')
</code></pre>

<p><strong>And here is the error message I get when I try to run it:</strong></p>

<pre><code>Traceback (most recent call last):
  File "dbox.py", line 7, in &lt;module&gt;
    dbx.files_upload(data, '/file.txt')
  File "/usr/local/lib/python3.4/dist-packages/dropbox/base.py", line 1225, in files_upload
    f,
  File "/usr/local/lib/python3.4/dist-packages/dropbox/dropbox.py", line 249, in request
    timeout=timeout)
  File "/usr/local/lib/python3.4/dist-packages/dropbox/dropbox.py", line 341, in request_json_string_with_retry
    timeout=timeout)
  File "/usr/local/lib/python3.4/dist-packages/dropbox/dropbox.py", line 385, in request_json_string
    type(request_binary))
TypeError: expected request_binary as binary type, got &lt;class 'str'&gt;
</code></pre>

<p><strong>I've tried it different ways:</strong></p>

<p><strong>1.</strong></p>

<pre><code>with open("/home/pi/Desktop/dbox/asd.txt", "rb") as f:
    dbx.files_upload(f, '/asd.txt', mute = True)
</code></pre>

<p><strong>2.</strong></p>

<pre><code>dbx.files_upload("hello", "")
</code></pre>

<p><strong>3.</strong></p>

<pre><code>dbx.files_upload("hello", "/")
</code></pre>

<p>but I get the same error every time.</p>