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

kennyli_floqast's avatar
kennyli_floqast
Explorer | Level 3
4 months ago

How do i get the relative path for a folder?

My app is integrated with dropbox. However, I see some changes coming for business team dropbox:
https://help.dropbox.com/plans/upcoming-business-team-changes?_camp=16203&_tk=banner_campaign_format#moreorg

Within it, it says:

  • Switch integration file paths from absolute to relative, if available.
    • Browser URLs and absolute links will break once file paths change. Switching to relative means you won’t need to re-configure the paths after updating, but you can always manually configure the file paths after the update. 

 

Currently I'm using filesGetMetadata endpoint to get the path_display of a folder. I then pass in that path_display to filesListFolder endpoint. However, I'm under the assumption that this path_display is absolute. How can i get the relative path of a folder? Currently I'm unable to get a response from filesListFolder endpoint for business team dropbox after they went through the changes but it works with regular dropbox accounts. (however, i haven't added the “Dropbox-API-Path-Root” header)

Would I simply have to add the “Dropbox-API-Path-Root” header? Or would I need to call a new endpoint to get a relative path? Company doesn't have a dropbox teams account for me to test against so trying to understand what changes I need a little better before I push up these changes and test against client's instance.

Also if I add “Dropbox-API-Path-Root” header to make the filesListFolder API call for a normal dropbox account (not teams), will that start breaking things?

 

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

    Apps using the Dropbox API should continue using the same API methods/endpoints, such as filesListFolder and filesListFolderContinue, and the same properties such as path_lower or path_display, however you may need to make some changes, such as to start using the “Dropbox-API-Path-Root” header to make sure you're accessing the desired content. For instance, using the “Dropbox-API-Path-Root” header is necessary in order to access the contents of a team space.

     

    Please read the following resources for information on how to use the API to interact with a team space:

    • kennyli_floqast's avatar
      kennyli_floqast
      Explorer | Level 3

      Thanks! My code originally worked with team space but seems like they're rolling out changes. Not sure whats wrong with my existing code (I am already setting path-root). Does it have to be empty?

       

      /**
       * @param {Authorization} authorization
       */
      function createDropboxInstance(authorization) {
          const dropboxOptions = {
              accessToken: authorization.access_token,
          };
          if (authorization.rootNamespaceId) {
              Object.assign(dropboxOptions, {
                  pathRoot: JSON.stringify({
                      '.tag': 'root',
                      root: `${authorization.rootNamespaceId}`,
                  }),
              });
          }
          return new DropboxSDK.Dropbox(dropboxOptions);
      }
      
      
      
      async fetchFilesAndFolders(storage, authorization) {
              const dropboxSDKInstance = createDropboxInstance(authorization);
              const folderMetadata = await this._folderInfoInternal(
                  storage,
                  authorization
              );
      
              return new Promise((resolve, reject) => {
                  const retryCallback = makeRetryCallback(resolve, reject);
      
                  retry(
                      Dropbox.retryOptions,
                      (callback) => {
                          dropboxSDKInstance
                              // @ts-ignore
                              .filesListFolder({ path: folderMetadata.path_display })
                              .then((response) => callback(null, response))
                              .catch((error) => {
                                  this._logger.error(
                                      formatLoggerErrors(
                                          error,
                                          'fetchFilesAndFolders'
                                      )
                                  );
                                  this._logger.error(error);
                                  callback(
                                      StorageProviderError(
                                          this.name,
                                          error.status ? error.status : 500,
                                          1005,
                                          error.error
                                      )
                                  );
                              });
                      },
                      retryCallback,
                      this._logger
                  );
              });
          }

       

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

        There are a number of ways to use the functionality, depending on what you're trying to do, but the pathRoot field, if being used, should not be empty. In order to access the team space, for instance, you should use the root mode and use the root namespace ID for the connected account.

         

        To clarify, is something in particular currently not working as expected? Please feel free to share the specific error/unexpected output and I'll be happy to take a look.

         

        Note that if you need a test team, you can request one using the process described under the "How do I test my application?" question here. Be sure to indicate what specifically you need to test.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,885 PostsLatest Activity: 5 years ago
326 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!