cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Query Dropbox API with `select_user` URL parameter

Query Dropbox API with `select_user` URL parameter

bipalshakya
Explorer | Level 4
Go to solution

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?

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

[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.

 

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution

[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
Explorer | Level 4
Go to solution

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
Dropbox Staff
Go to solution

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.

bipalshakya
Explorer | Level 4
Go to solution

Thanks, Greg for the clarification.

 

Will proceed accordingly. Hoping that the API is updated to return JSON serializable object soon!

Need more support?