<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Upload file to sharing folder using Python Package in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-file-to-sharing-folder-using-Python-Package/m-p/688282#M30911</link>
    <description>&lt;P&gt;I want to figure out how I can upload a file to sharing folder. I have tried following code to upload a file to dropbox. Rather than uploading the file to shared folder "Reports", it uploaded it to my "userfolder/Reports" I tried various options but nothing worked out. I was able to get the shared folder id for the shared folder but there is no shared_path set for the folder. Let me know what else I can do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import dropbox


DROPBOX_ACCESS_TOKEN = 'TOKEN'


def dropbox_connect():
    """Create a connection to Dropbox."""

    try:
        dbx = dropbox.Dropbox(DROPBOX_ACCESS_TOKEN)
        print('Connected to Dropbox successfully')
    except AuthError as e:
        print('Error connecting to Dropbox with access token: ' + str(e))
    return dbx

    

dbx = dropbox_connect()

file_path = 'PATHNAME'

# Specify the path to the folder. Here Reports should be a shared folder
destination_path = '/Reports/test.pdf'


# Upload the file to the folder
try:
    with open(file_path, 'rb') as file:
        response = dbx.files_upload(file.read(), destination_path)
        print('File uploaded to shared folder:', response.name)
except FileNotFoundError:
    print('File not found:', file_path)
except dropbox.exceptions.ApiError as e:
    print('Error uploading file:', e)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 31 May 2023 22:14:31 GMT</pubDate>
    <dc:creator>urvisheth</dc:creator>
    <dc:date>2023-05-31T22:14:31Z</dc:date>
    <item>
      <title>Upload file to sharing folder using Python Package</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-file-to-sharing-folder-using-Python-Package/m-p/688282#M30911</link>
      <description>&lt;P&gt;I want to figure out how I can upload a file to sharing folder. I have tried following code to upload a file to dropbox. Rather than uploading the file to shared folder "Reports", it uploaded it to my "userfolder/Reports" I tried various options but nothing worked out. I was able to get the shared folder id for the shared folder but there is no shared_path set for the folder. Let me know what else I can do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import dropbox


DROPBOX_ACCESS_TOKEN = 'TOKEN'


def dropbox_connect():
    """Create a connection to Dropbox."""

    try:
        dbx = dropbox.Dropbox(DROPBOX_ACCESS_TOKEN)
        print('Connected to Dropbox successfully')
    except AuthError as e:
        print('Error connecting to Dropbox with access token: ' + str(e))
    return dbx

    

dbx = dropbox_connect()

file_path = 'PATHNAME'

# Specify the path to the folder. Here Reports should be a shared folder
destination_path = '/Reports/test.pdf'


# Upload the file to the folder
try:
    with open(file_path, 'rb') as file:
        response = dbx.files_upload(file.read(), destination_path)
        print('File uploaded to shared folder:', response.name)
except FileNotFoundError:
    print('File not found:', file_path)
except dropbox.exceptions.ApiError as e:
    print('Error uploading file:', e)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 22:14:31 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-file-to-sharing-folder-using-Python-Package/m-p/688282#M30911</guid>
      <dc:creator>urvisheth</dc:creator>
      <dc:date>2023-05-31T22:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Upload file to sharing folder using Python Package</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-file-to-sharing-folder-using-Python-Package/m-p/688340#M30912</link>
      <description>&lt;P&gt;Hi &lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1710238"&gt;@urvisheth&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;If nothing else has been set, by default all file/folder path are rooted on the user folder, not to something else! On individual accounts user folder match to the account root and that why nothing need to be added. On group account, like business subscription, one account has more users and that's why both folder differs. To access something with account root based path or based to some other namespace, you have to set that namespace, the one that's not the default. &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@41457EF40051AFF130FDBFE21B496926/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/P&gt;&lt;P&gt;Hope this gives direction.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 07:41:22 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-file-to-sharing-folder-using-Python-Package/m-p/688340#M30912</guid>
      <dc:creator>Здравко</dc:creator>
      <dc:date>2023-06-01T07:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: Upload file to sharing folder using Python Package</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-file-to-sharing-folder-using-Python-Package/m-p/688419#M30913</link>
      <description>&lt;P&gt;&lt;a href="https://www.dropboxforum.com/t5/user/viewprofilepage/user-id/1710238"&gt;@urvisheth&lt;/a&gt; I see you want to upload a file to a shared folder in your team space, not your own folder. By default, API calls operate in the "member folder" of the connected account, not the "team space". You can configure API calls to operate in the "&lt;A href="https://help.dropbox.com/teams-admins/team-member/team-space-overview" target="_blank" rel="noopener noreferrer"&gt;team space&lt;/A&gt;" instead though. To do so, you'll need to set the "Dropbox-API-Path-Root" header. You can find information on this in &lt;A href="https://developers.dropbox.com/dbx-team-files-guide" target="_blank" rel="noopener noreferrer"&gt;the Team Files Guide&lt;/A&gt;. With the Python SDK, you can set that header using &lt;A href="https://dropbox-sdk-python.readthedocs.io/en/latest/api/dropbox.html#dropbox.dropbox_client.Dropbox.with_path_root" target="_blank"&gt;the with_path_root method&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 14:12:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Upload-file-to-sharing-folder-using-Python-Package/m-p/688419#M30913</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2023-06-01T14:12:54Z</dc:date>
    </item>
  </channel>
</rss>

