We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

bipalshakya's avatar
bipalshakya
Explorer | Level 4
4 years ago

Query Dropbox API with `select_user` URL parameter

Hi there!

So what I'm trying to do is query Dropbox using python's from dropbox import DropboxTeam's request_json_object API.
I want to query the API path: files/list_folder.

My request dictionary that I pass to the function is as following:

 

request_json_object(dict(
    host='api',
    auth_type='team',
    route_style='rpc',
    request_binary=None,
    route_name='files/list_folder',
    request_arg={'limit': 1, 'select_user': 'userid:111...111'}
))

 


However, I am getting a BadInputError error:

> 'Error in call to API function "files/list_folder": This API function operates on a single Dropbox account, but the OAuth 2 access token you provided is for an entire Dropbox Business team. Since your API app key has team member file access permissions, you can operate on a team member\'s Dropbox by providing the "Dropbox-API-Select-User" HTTP header or "select_user" URL parameter to specify the exact user <https://www.dropbox.com/developers/documentation/http/teams>.'


What am I doing wrong here?

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

    [Cross-linking for reference: https://stackoverflow.com/questions/66247055/query-dropbox-api-with-select-user-url-parameter ]

     

    First, note that you don't need to use `request_json_object` directly. You generally should use the native methods provided for each endpoint. In the official Dropbox Python SDK, for /2/files/list_folder, that would be `files_list_folder`.

     

    And to set the the"Dropbox-API-Select-User" HTTP header when using the official Dropbox Python SDK, you should do so via the `DropboxTeam.as_user` method.

     

    • bipalshakya's avatar
      bipalshakya
      Explorer | Level 4

      Hi, 
      Thanks for the prompt response.

       

      The reason that I opted for request_json_object was that I would get JSON output, which is the format that I need the results in.

      With the SDK however, I'd get a Dropbox object.

       

      Is there a way that I could get the response from SDK in JSON? Or a way I could transform the Dropbox object response to JSON or python dictionary?

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

        The methods for calling the API in the Dropbox Python SDK like files_list_folder don't offer the original JSON, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though. 

         

        You can transform the information in the returned native object, such as ListFolderResult for files_list_folder, however you wish. You'd need to write the code to do so though, e.g., to build some JSON.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,877 PostsLatest Activity: 2 hours 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!