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

Info V.1's avatar
Info V.1
Collaborator | Level 8
6 years ago

How to full absolute path of a team folder using the namespace id?

We use full path to track dropbox files in our system. When a file is added in a team folder then we get an event that has "contextual" path. But when an external user drop a file then it does not have this field.

So, how can I get full path of the team folder using its namespace id.

 

  • Greg-DB's avatar
    Greg-DB
    6 years ago

    For items in the team space you can still use /2/files/get_metadata to get the metadata, such as the `path_lower`. For instance, that may look like:

     

    curl -X POST https://api.dropboxapi.com/2/files/get_metadata \
        --header "Authorization: Bearer <ACCESS_TOKEN>" \
        --header "Dropbox-API-Select-Admin: <ADMIN_ID>" \
        --header "Content-Type: application/json" \
        --header 'Dropbox-API-Path-Root: {".tag": "root", "root": "<TEAM_SPACE_ID>"}' \
        --data "{\"path\": \"ns:<SHARED_FOLDER_ID>\"}"
    

     

     

  • Could you please clarify your question a bit?

    If possible, could you give me an example of what you're currently getting back as well as an example of what you're trying to do (what you want the data to look like)?

    • Info V.1's avatar
      Info V.1
      Collaborator | Level 8

      Below is the event when a team member uploads file, note that it has field "contextual" under assets>path.

      {
                  "timestamp": "2019-05-23T01:11:12Z",
                  "event_category": {
                      ".tag": "file_operations"
                  },
                  "actor": {
                      ".tag": "user",
                      "user": {
                          ".tag": "team_member",
                          "account_id": "dbid:AAC4XXXXXXXXXXXXuv8oCqkHpcyLw",
                          "display_name": "Andy Dwyer",
                          "email": "adwyer@veraqa.net",
                          "team_member_id": "dbmid:AAAJXXXXXLroYqf-A7hFdXXXXXX70WUmWw"
                      }
                  },
                  "origin": {
                      "geo_location": {
                          "city": "Sunnyvale",
                          "region": "California",
                          "country": "US",
                          "ip_address": "96.95.218.202"
                      },
                      "access_method": {
                          ".tag": "end_user",
                          "end_user": {
                              ".tag": "web",
                              "session_id": ""
                          }
                      }
                  },
                  "involve_non_team_member": false,
                  "context": {
                      ".tag": "team_member",
                      "account_id": "dbid:AAC4N0gXXXXXXXXuv8oCqkHpcyLw",
                      "display_name": "Andy Dwyer",
                      "email": "adwyer@veraqa.net",
                      "team_member_id": "dbmid:AAXXXXXlPLroYqf-A7hFd3XXXXXX0WUmWw"
                  },
                  "participants": [],
                  "assets": [
                      {
                          ".tag": "folder",
                          "path": {
                              "contextual": "/Sales/external/folder_creation_test",
                              "namespace_relative": {
                                  "ns_id": "5568891184",
                                  "relative_path": "/folder_creation_test"
                              }
                          },
                          "display_name": "folder_creation_test",
                          "file_id": "id:tG_h5JeqH1XXXXXAAAB1wQ"
                      }
                  ],
                  "event_type": {
                      ".tag": "file_add",
                      "description": "Added files and/or folders"
                  },
                  "details": {
                      ".tag": "file_add_details"
                  }
              }

      Now, below is the event when external user drops a file , note this does not have field "contextual" under assets>path.

      {
                  "timestamp": "2019-05-21T06:30:07Z",
                  "event_category": {
                      ".tag": "file_operations"
                  },
                  "actor": {
                      ".tag": "app",
                      "app": {
                          ".tag": "user_linked_app",
                          "app_id": "dbaid:AACd5ER5-nbkf7XXXXXk8_ArXJQkQshU",
                          "display_name": "Dropbox for Android"
                      }
                  },
                  "origin": {
                      "geo_location": {
                          "city": "San Jose",
                          "region": "California",
                          "country": "US",
                          "ip_address": "2601:646:8700:42b0:dc48:3e00:ce93:310a"
                      },
                      "access_method": {
                          ".tag": "api",
                          "request_id": "dbarid:73b4349e346cf6d6939d103ea76adad7"
                      }
                  },
                  "involve_non_team_member": true,
                  "context": {
                      ".tag": "non_team_member",
                      "account_id": "dbid:AAD0uHlPDbAjch1-21c5LFXXXXVBalczE",
                      "display_name": "Manish Agarwal",
                      "email": "itsmanishagarwal@gmail.com"
                  },
                  "participants": [],
                  "assets": [
                      {
                          ".tag": "file",
                          "path": {
                              "namespace_relative": {
                                  "ns_id": "5561881552",
                                  "relative_path": "/IMG_20190520_233130.jpg"
                              }
                          },
                          "display_name": "IMG_20190520_233130.jpg",
                          "file_id": "id:WSl52hXXXXAAAAAAAAADXA"
                      }
                  ],
                  "event_type": {
                      ".tag": "file_add",
                      "description": "Added files and/or folders"
                  },
                  "details": {
                      ".tag": "file_add_details"
                  }
              }

      Now, how can I find the contextual path for the above namespace (ns_id:5561881552)?

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

        Thanks, that's helpful. First, for reference, the "contextual" path is the "fully qualified path relative to event's context". 

        In the first case, the event's context is a 'team_member', so your app has access to the information about the full path in that particular team member's account.

        In the second case however, the event's context is a 'non_team_member', so your app does not have access to the information about the full path in the non team member's account. I.e., for a particular shared folder, the user can put that shared folder anywhere in their account that they want. Since your app isn't authorized to the rest of their account though, it can't see the rest of the path, e.g., any parent folders.

        So, to summarize, while your app gets events for the shared folder since it's owned by your team in general, since this event is from a non-team member, it doesn't get the contextual information about that shared folder's location in that non-team member's account.

        Further, there isn't necessarily a single answer as to "where" the shared folder is located in your team members' accounts. The shared folder may be at different locations in different accounts. 

        If you're using an app with the team member file access permission though, you can use the team member file access feature to list the members of any particular shared folder using /2/sharing/list_folder_members[/continue], and then look up the information for a particular shared folder in a particular team member's account, such as where the folder is located, using /2/files/get_metadata.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,882 PostsLatest Activity: 3 years ago
325 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!