Take Your Search Game to the Next Level with Dropbox Dash  🚀✨ Curious how it works? Ask us here! 

Forum Discussion

rafstahelin's avatar
rafstahelin
New member | Level 2
27 days ago

API Path Resolution Issue with Lambda Function

Dropbox Forum Post: API Path Resolution Issue with Lambda Function

The Problem I'm having an issue with my AWS Lambda function that uploads files from an S3 bucket to Dropbox. Despite using a token generated from my team account, all files are being uploaded to my personal account path with the team folder as a subfolder, rather than directly to the team space.

Current vs. Desired Behavior

  • Current path: /personal_account/team_folder/ai/output/output-eagle.library/output-eagle/
  • Desired path: /team_folder/ai/output/output-eagle.library/output-eagle/

Technical Implementation My Lambda function uses the standard Dropbox API to upload files:

python

response = http.request( 'POST', 'https://content.dropboxapi.com/2/files/upload', body=file_data, headers={ 'Authorization': f'Bearer {dropbox_token}', 'Content-Type': 'application/octet-stream', 'Dropbox-API-Arg': json.dumps({ 'path': f'/team_folder/ai/output/output-eagle.library/output-eagle/{filename}', 'mode': 'add', 'autorename': True }) } )

What I've Tried

  1. Created multiple tokens while logged into my team account
  2. Tried different path formats in the API call:
    • /team_folder/path/to/folder
    • //team_folder/path/to/folder
    • /path/to/folder (without team folder prefix)
  3. Tried adding path_root parameter with namespace ID
  4. Linked team to the app in Developer Console

Interesting Observation When I use rclone with the same account credentials, I can access the team folder directly using the path /team_folder/... without any issues. This suggests I have the proper permissions, but something specific in the API implementation is causing the issue.

Questions

  1. How can I correctly specify a path to upload directly to my team space?
  2. Is there a specific header or parameter needed when using the API that rclone might be using automatically?
  3. Are different token types needed for accessing team spaces vs. personal spaces?

Any guidance would be greatly appreciated as this is for an automated workflow that transfers images from AWS to Dropbox for my team's use.

8 Replies

  • DB-Des's avatar
    DB-Des
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    21 days ago

    Hi rafstahelin​,

    It looks like you have been in communication with our support team. We can continue assisting you through that channel.

  • rafstahelin's avatar
    rafstahelin
    New member | Level 2
    23 days ago

    Is there any way to receive a more direct support on this matter. I am not an engineer and have been on this for a week. This is very difficult

  • rafstahelin's avatar
    rafstahelin
    New member | Level 2
    23 days ago

    Progress So Far:

    Critical Information Retrieved:

    Obtained my root namespace ID: xxxxxxxx
    Obtained my member ID: xxxxxxx
    Added team_data.content.write and other team permissions to my app

    Implementation:

    Successfully modified my AWS Lambda function to include both the namespace ID and member ID
    Implemented the correct headers as advised
    Updated my access token after adding the new permissions
    Simplified the target path to /output-eagle/{filename} to eliminate potential path complexity issues

    Current Issue:
    Despite implementing all the recommended changes, I'm still receiving a "409 Conflict" error with the message:
    {"error_summary": "path/no_write_permission/...", "error": {".tag": "path", "reason": {".tag": "no_write_permission"}, "upload_session_id": "pid_upload_session:ABIJH3zrQHGELnZnhSrIXYOcu2U9_8zfcTi0nbk8vg-kKQkKnA"}}
    Current API Request Details:
    python# Headers being sent:
    headers = {
    'Authorization': f'Bearer {dropbox_token}',
    'Content-Type': 'application/octet-stream',
    'Dropbox-API-Select-User': 'xxxxxxx',
    'Dropbox-API-Path-Root': json.dumps({
    ".tag": "namespace_id",
    "namespace_id": "xxxxxxxxx"
    }),
    'Dropbox-API-Arg': json.dumps({
    'path': '/output-eagle/filename.jpg',
    'mode': 'add',
    'autorename': True,
    'mute': False
    })
    }

    also tried:
    headers = {
        'Authorization': f'Bearer {access_token}',
        'Dropbox-API-Select-User': member_id,
        'Dropbox-API-Path-Root': json.dumps({
            ".tag": "root",  # Changed from "namespace_id"
            "root": root_namespace_id
        }),
        # Other headers...
    }


    I've confirmed that:

    My access token was refreshed after adding the permissions
    I'm using the correct member ID and namespace ID
    My app has the following permissions enabled:

    team_data.member
    team_data.team_space
    team_data.content.write
    files.team_metadata.write
    files.team_metadata.read

     

     

    What else should I check? Am I missing something in my implementation, or could there be a team-level permission issue that I need to address?

  • DB-Des's avatar
    DB-Des
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    25 days ago

    rafstahelin​ 

    What you are wanting to retrieve from the response from the /2/users/get_current_account endpoint is the user's 'root_namespace_id'.

    Feel free to share the response you are receiving so we can better assist. Please remove any personal identifiable information though.

  • rafstahelin's avatar
    rafstahelin
    New member | Level 2
    26 days ago

    I've set these permissions:

    • files.content.write
    • files.content.read
    • team_data.member
    • team_data.content.write
    • team_data.content.read


    not sure what i am missing. 

  • rafstahelin's avatar
    rafstahelin
    New member | Level 2
    26 days ago

    thanks for that. only thing is i cannot find my 

    i am running:

    curl -X POST https://api.dropboxapi.com/2/users/get_current_account \
      --header "Authorization: Bearer YOUR_ACCESS_TOKEN"

    but i am not getting my YOUR_NAMESPACE_ID back. is there another way of getting it? 

  • DB-Des's avatar
    DB-Des
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    26 days ago

    Hi rafstahelin​ 

    To add to what jdalessio shared, by default, API calls to the Dropbox API operate in the "member folder" of the connected account, not the "team space". That means that by default, the contents of the team space will not be found.
     
    You can configure API calls to operate in the "team space" instead though, in order to interact with files/folders in the team space. To do so, you'll need to set the "Dropbox-API-Path-Root" header. You can find information on how to use this in the Team Files Guide.

    I hope you find this information helpful!

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,012 PostsLatest Activity: 34 minutes ago
394 Following

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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!