Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

sandeepkshyam's avatar
sandeepkshyam
New member | Level 2
9 years ago
Solved

couldn't upload using a python script

hi

i am trying to use this simple python code to upload but it doesn't seem to work, the output looks fine with no errors, but the file is never uploaded, when i try the same curl command on command prompt it works fine.

 

p = subprocess.Popen("curl -X POST https://content.dropboxapi.com/2/files/upload --header \"Authorization:Bearer <ACCESS_TOKEN_REDACTED>\" --header \"Dropbox-API-Arg:{\"path\":\"/m40_debug.log\",\"mode\":\"add\",\"autorename\":true,\"mute\":false}\" --header \"Content-Type:application/octet-stream\" --data-binary @abcd.log", stdout=subprocess.PIPE, stderr=None, shell=True)
stdout, stderr = p.communicate()
  • i checked with curl -v and see i always get 400 bad request, reason might be as quotes are missing in json object, not sure though, does anyone have any working way to upload curl command using python subprocess.Popen command


3 Replies

  • sandeepkshyam's avatar
    sandeepkshyam
    New member | Level 2
    9 years ago

    i checked with curl -v and see i always get 400 bad request, reason might be as quotes are missing in json object, not sure though, does anyone have any working way to upload curl command using python subprocess.Popen command


  • sandeepkshyam's avatar
    sandeepkshyam
    New member | Level 2
    9 years ago
    got it resolved with a extra single quote before start of Dropbox-API-Arg
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    I'm glad to hear you got this sorted out already. For future reference, if you check the response body, it should contain a more specific error message indicating the issue.

     

    By the way, I redacted it from your post, but since you initially posted your access token, for the sake of security, you should disable that access token. You can do so by revoking access to the app entirely, if the access token is for your account on the account security pageOr, you can disable just this access token using the API. You would need to then get a new access token and plug that in to your app instead.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If 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, Facebook or Instagram.

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!