DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Revolutionizing Financial Monitoring: Building a Team Dashboard With OpenObserve
  • 3 Reasons Why VPs of Engineering Are Choosing Low-Code
  • Be a Better Team Player
  • The Rising Risks and Opportunities in API Security

Trending

  • How Clojure Shapes Teams and Products
  • Java's Quiet Revolution: Thriving in the Serverless Kubernetes Era
  • Scalability 101: How to Build, Measure, and Improve It
  • Fixing Common Oracle Database Problems
  1. DZone
  2. Data Engineering
  3. Databases
  4. Dropbox API Tips: Working With Dropbox Namespaces

Dropbox API Tips: Working With Dropbox Namespaces

Explore Dropbox API tips as well as look at Dropbox namespaces.

By 
Jord Lin user avatar
Jord Lin
·
Apr. 01, 19 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
14.2K Views

Join the DZone community and get the full member experience.

Join For Free

A Dropbox namespace is a collection of files and folders that are within a single shared folder, team folder, app folder, or within a team’s root folder or a user’s home folder. Namespaces provide the ability to access these types of folders and their contents without having to specify the entire path the folder is mounted to in each API request. This is beneficial since a folder’s path could differ between users for the same shared folder. Dropbox’s guide to namespaces provides an introduction to namespaces and how to access them via the API. Below, we dive into some of the details with accessing content in team folders and how to get started.Image title

Accessing Team Folders

The first approach we took to access team folder data as a team member was to call the sharing/list_folders endpoint to retrieve a list of shared resources. Filtering out the items where is_team_folder is false lets us identify the team folders to retrieve further metadata on. However, using the folders’ namespace IDs like the Dropbox guide suggests returns a 404 error:

curl -X POST "https://api.dropboxapi.com/2/files/get_metadata" \
    --header 'Authorization: Bearer TOKEN' \
    --data '{"path":"ns:2744814537"}'

{
  "error_summary": "path/not_found/",
  "error": {
    ".tag": "path",
    "path": {
      ".tag": "not_found"
    }
  }
}

It turns out it isn’t possible to access namespaces that are not within the currently authenticated member’s home folder. To understand why, let’s look into the differences between a Dropbox root folder and home folder and what the Path Root represents.

Root vs. Home

For Dropbox Business users, each team shares a team space that all members can access. As a result, the folder layout and path to team space content is the same for each team member. The top-level folder for a team space is considered to be the “root,” representing the team’s root folder.

Team spaces allow two kinds of folders — team member folders and team folders.

Team member folders are individual members’ private folders, each representing a member’s “home” folder. These are private to that team member unless content within them is shared with other members or externally.

Team folders, however, are always shared with team members although each member may have different levels of permissions to the content within, such as read-only privileges.

To retrieve the root and home namespace IDs for a user, call the users/get_current_account endpoint. The excerpt shown below from the response provides an example of the type of identification information returned:

    {
      ...
      "root_info": {
        ".tag": "team",
        "root_namespace_id": "7",
        "home_namespace_id": "1",
        "home_path": "/Sarah"
      }
    }

The Path Root

The Dropbox API Path Root is the folder that an API request operates relative to. Including the Dropbox-API-Path-Root header, which enables apps to avoid including the namespace in each path referenced in API requests. By default, the Path Root in API requests is the currently authenticated member’s home folder. Since the home folder is within a team space, this makes it impossible to access other team folders that are at the same level as the home folders within a team space. To solve this, Dropbox allows API requests to set the Dropbox-API-Path-Root header to {".tag": "root", "root": ROOT_NAMESPACE_ID}to perform operations relative to the root folder instead of the default home folder. This JSON object format is referred to in the docs as the “root mode” of operation.

This solves the issue with the first API request above that resulted in a 404. Escalating the relative path root from the home folder to a team’s root folder enables the app to retrieve metadata for the team folder:

curl -X POST "https://api.dropboxapi.com/2/files/get_metadata" \     
  -H 'Authorization: Bearer TOKEN' \     
  -H 'Dropbox-API-Path-Root: {".tag": "root", "root": "2744814544"}' \
  -d '{"path":"ns:2744814537"}'

Let us know your thoughts in the comments!

API Dropbox (service) teams

Published at DZone with permission of Jord Lin. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Revolutionizing Financial Monitoring: Building a Team Dashboard With OpenObserve
  • 3 Reasons Why VPs of Engineering Are Choosing Low-Code
  • Be a Better Team Player
  • The Rising Risks and Opportunities in API Security

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: