You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

cristrod817's avatar
cristrod817
Explorer | Level 3
2 years ago

Dropbox's code example for sharing a file link in Python not working

#Python code provided by Dropbox
import requests
import json

headers = {
    "Authorization": "Bearer append-current-token"
"Content-Type": "application/json"
}
data = {
    "path": "/baby dream/Cris Rodriguez/10yrsZ.tif"
}

r = requests.post(url, headers=headers, data=json.dumps(data))
print(r.text)
 
I am getting this error text: 400
 
Error in call to API function "sharing/get_shared_link_metadata":
This function requires its argument in the HTTP request body, but your request body is empty.
 
This is the default code provided by Dropbox which I am trying to implement but to no avail.
I've done my research to no avail.  Need help desperately.
 
I am using VS Code as my editor, Windows 10 latest version, Python 3.10.10



  • cristrod817, as Greg pointed out, 'url' parameter is missing in your request and of course, the error message, you're receiving, notes the same. Take a look once again in the link you post above. There are 3 parameters - 1 mandatory and 2 optional. You have put only one of the optional params. 🙂 Where is the link you want to check metadata for? That's it.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Can you let me know where you found or received this code so I can check on that?

     

    In any case, is this the actual/exact code you're running? When I plug in an access token, and add the missing "," in the 'headers' object that otherwise causes a SyntaxError, I actually get the different error "Error in call to API function "sharing/get_shared_link_metadata": request body: missing required field 'url'" which would be expected in this case for this code, as the /2/sharing/get_shared_link_metadata endpoint requires a 'url' parameter.

      • Здравко's avatar
        Здравко
        Legendary | Level 20

        cristrod817, as Greg pointed out, 'url' parameter is missing in your request and of course, the error message, you're receiving, notes the same. Take a look once again in the link you post above. There are 3 parameters - 1 mandatory and 2 optional. You have put only one of the optional params. 🙂 Where is the link you want to check metadata for? That's it.