We’re aware of an issue causing slower load times on the Dropbox Community forum. It should be resolved soon. Thanks for your patience! 

Forum Discussion

rgahan's avatar
rgahan
Explorer | Level 4
4 years ago
Solved

Cast dropbox class to JSON

I am using the Python Dropbox package to pull team events:

```
dbx = dropbox.DropboxTeam(self.access_token)
result = dbx.team_log_get_events()
```

I need to pass the value of `result` along as a JSON object. When I try using `json.dumps(result)`, I get this error:
> TypeError: Object of type GetTeamEventsResult is not JSON serializable

Is there a way to cast to json/dict with the Dropbox package?

My other potential solutions would be to write my own method to cast it (seems tedious) or just make API calls instead of using the package.

  • [Cross-linking for reference: https://stackoverflow.com/questions/70041701/cast-dropbox-class-to-json ]

     

    The methods for calling the API in the Dropbox Python SDK don't return JSON-serializable objects (or the original JSON from the server), 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 however you wish, but you'd need to write the code to do so though unfortunately, as you mentioned.

1 Reply

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    4 years ago

    [Cross-linking for reference: https://stackoverflow.com/questions/70041701/cast-dropbox-class-to-json ]

     

    The methods for calling the API in the Dropbox Python SDK don't return JSON-serializable objects (or the original JSON from the server), 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 however you wish, but you'd need to write the code to do so though unfortunately, as you mentioned.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

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, Facebook or Instagram.

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!