cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dropbox API for Python: Can't Create Shared Link (CreateSharedLinkError, malformed path)

Dropbox API for Python: Can't Create Shared Link (CreateSharedLinkError, malformed path)

Jim_Hagerty
New member | Level 2

I'm having trouble getting a shareable link from a file through the Dropbox API. This is the entirety of my code:

import os
import dropbox
dbx = dropbox.Dropbox('access token')
myPath = os.path.join("E:\\Dropbox\\DUNESBURY NEW ITEM PICS\\2019\\01 January\\Originals\\Flowers\\DSC_0247.NEF")
dbx.sharing_create_shared_link(path = myPath, short_url=False, pending_upload=None)

 This throws the error:

dropbox.exceptions.ApiError: ApiError('dd1d6711a935e6b6fd04c192fd58bfca', CreateSharedLinkError('path', LookupError('malformed_path', None)))

I'm trying to get this script to print links like this: https://www.dropbox.com/s/fcdljiu8hjv3g7u/DSC_0247.NEF?dl=0, and write them to a .txt file, so I can automate the process for us getting links out of Dropbox.

Am I on the right track? How can I resolve this error?

1 Reply 1

Greg-DB
Dropbox Staff

When you make a Dropbox API call like this and supply a path, you should supply the path to the remote file on Dropbox, relative to the root of the Dropbox account. 

In the code you shared here, you're instead sharing a path to the local file, which isn't a valid path for the Dropbox API.

That is, based on the sample you shared, the path value should instead look like:

"/DUNESBURY NEW ITEM PICS/2019/01 January/Originals/Flowers/DSC_0247.NEF"

(You can get these values from elsewhere on the API, such as in Metadata.path_lower, e.g,. as returned by files_list_folder.)

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?