We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
homopoluza
7 months agoHelpful | Level 6
AssertionError: Expected content-type to be application/json, got 'application/grpc'
Hi, everybody! I have a simple Python script to create an archive and store it in Dropbox.
import subprocess
import os
import dropbox
import shutil
from datetime import datetime
class...
- 7 months ago
I just renewed the token, and all is good. Thank you for your time Greg-DB
Greg-DB
Dropbox Staff
Thanks for the report! This error indicates that the Dropbox API servers did not respond with the expected format.
I just tried this out myself though, and I wasn't able to reproduce this. This kind of issue could just be a result of temporary server issues. Are you still seeing this problem?
If you are still seeing this, please let me know:
- about what percent of your calls fail like this
- if this code was previously working for you, and if so, when you saw this problem start occurring
- whether or not other calls, such as `self.dbx.users_get_current_account()` also fail like this for you
homopoluza
7 months agoHelpful | Level 6
Sorry for the late reply.
- about what percent of your calls fail like this
All of them
- if this code was previously working for you, and if so, when you saw this problem start occurring
No, this is a new script for me, I wrote it with the help of this post
https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/python-upload-big-file-example/td-p/166626
It worked for others without problems. - whether or not other calls, such as `self.dbx.users_get_current_account()` also fail like this for you
Unfortunately yes. The token was provided to me by my colleague. Could it be restrictions of trial account perhaps?
print(dbx.users_get_current_account()) AssertionError: Expected content-type to be application/json, got 'application/grpc'
Thank you for your assistance
- Greg-DB7 months agoDropbox Staff
Thanks for following up. The API functionality you're attempting to use is available to all Dropbox plans/trials, and even if an API error is returned, it shouldn't be sent with that Content-Type.
It's unclear what would be causing this, so we'll need to look into this further. Can you please try running the following at least 5 times and send me the output? This will enable more verbose output which may be helpful for investigating this issue:
import http.client http.client.HTTPConnection.debuglevel = 1 import dropbox dbx = dropbox.Dropbox('ACCESS_TOKEN_HERE') print(dbx.users_get_current_account())
Be sure to replace ACCESS_TOKEN_HERE with the access token you're using. As long as that access token starts with "sl." and it has been more than four hours since the access token has been created, please leave it in the output as it would be expired anyway and may be helpful for investigating this.
- homopoluza7 months agoHelpful | Level 6
after multiple times
the outputbazhin@DESKTOP-2IOFFID:~/dropbox$ /usr/bin/env /bin/python3 /home/bazhin/.vscode-server/extensions/ms-python.debugpy-2024.4.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 42309 -- /home/bazhin/dropbox/test2.py send: b'POST /2/users/get_current_account HTTP/1.1\r\nHost: api.dropboxapi.com\r\nUser-Agent: OfficialDropboxPythonSDKv2/11.36.2\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nAuthorization: Bearer sl.BznBUIsodC4OmcMX9vn7wX6TOTMiFbTfTF7preTpNpCWTwG_hwF3p30YXdak\xadKcgIDP5CggtIwJ1ScpQWlPNfVggJQLY2uIEPAQdLTFyVvsSnF_mIN8Ji52N1\xadXkQljr3_5RiJPNPVFEwq\r\nContent-Type: application/json\r\nContent-Length: 4\r\n\r\n' send: b'null' reply: 'HTTP/1.1 401 Unauthorized\r\n' header: Content-Type: application/grpc header: Date: Tue, 23 Apr 2024 05:59:06 GMT header: Server: envoy header: Content-Length: 0 header: X-Dropbox-Response-Origin: far_remote header: X-Dropbox-Request-Id: 05ae29d6341d48268d19838cbfda16d5
the error
Exception has occurred: AssertionError Expected content-type to be application/json, got 'application/grpc' File "/home/bazhin/dropbox/test2.py", line 6, in <module> print(dbx.users_get_current_account()) AssertionError: Expected content-type to be application/json, got 'application/grpc'
- homopoluza7 months agoHelpful | Level 6
Well, I decided to create my own app for testing on my own current account.
Permission type - account_info.read - Scoped AppAnd
print(dbx.users_get_current_account())
works just fine now.
Then I added files.content.write permission and tried my script from the first post and gotException has occurred: AuthError AuthError('1c1aa051ebc4408297c28154348ecaf8', AuthError('missing_scope', TokenScopeError(required_scope='files.content.write'))) File "/home/bazhin/dropbox/dropbox_backup.py", line 15, in upload upload_session_start_result = self.dbx.files_upload_session_start(f.read(self.CHUNK_SIZE)) File "/home/bazhin/dropbox/dropbox_backup.py", line 54, in <module> uploader.upload(archive_name, archive_size) dropbox.exceptions.AuthError: AuthError('1c1aa051ebc4408297c28154348ecaf8', AuthError('missing_scope', TokenScopeError(required_scope='files.content.write')))
But I guess I have to wait for permission update or something, haven't I?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 24 minutes agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!