Forum Discussion

TheBadger's avatar
TheBadger
Explorer | Level 3
4 years ago

Get folder links

Hello, 

I've been tasked with creating shared folders for our team. Each team member will get their own folder that will contain files specific to them. I need a way to collect or create the shared links by automation rather than by copying and pasting as there are currently over 100 team members but this is likely to grow.  Doing it by hand has proven to be time consuming and error prone. 


Is it possible to do this automatically? I have some basic python knowledge but the API documentation is a little difficult. 

 

In the end I would like a csv file listing the folder name and the shared link.   Could someone point me in the right direction on this?

 

With thanks in advance,

James 

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

    Yes, you can use the Dropbox API to automate the creation of shared links. For Python, we recommend using the official Dropbox API v2 Python SDK:

     

    https://github.com/dropbox/dropbox-sdk-python

     

    With that, you can use the sharing_create_shared_link_with_settings method to create a shared link for any file or folder:

     

    https://dropbox-sdk-python.readthedocs.io/en/latest/api/dropbox.html#dropbox.dropbox_client.Dropbox.sharing_create_shared_link_with_settings

    • TheBadger's avatar
      TheBadger
      Explorer | Level 3

      Sorry I'm obviously not understanding the documentation because I keep getting an error. 

      The folder i want the link for is called test it's in the same directory as the python code.

       

      the_link = dbx.sharing_create_shared_link_with_settings('/test', settings=None)
      print(the_link)

       

       

      Traceback (most recent call last):
      File "D:\james\Dropbox\Project KMG Instructors\dropbox test.py", line 13, in <module>
      the_link = dbx.sharing_create_shared_link_with_settings('/test', settings=None)
      File "C:\Users\james\AppData\Local\Programs\Python\Python39\lib\site-packages\dropbox\base.py", line 4060, in sharing_create_shared_link_with_settings
      r = self.request(
      File "C:\Users\james\AppData\Local\Programs\Python\Python39\lib\site-packages\dropbox\dropbox_client.py", line 346, in request
      raise ApiError(res.request_id,
      dropbox.exceptions.ApiError: ApiError('21aabc3f746b4a0ca5f079118eb3a353', CreateSharedLinkWithSettingsError('path', LookupError('not_found', None)))

       

      Sorry I'm new to all this.

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

        The path, "/test" in your code here, should be referring to the path of the file or folder in the Dropbox account, not related to the location of the code you're running.

         

        I recommend reading the File Access Guide for reference.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,948 PostsLatest Activity: 37 minutes ago
351 Following

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 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!