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
jianliao
6 months agoExplorer | Level 4
Export legacy paper via python sdk does not work
Hi,
I am using the latest dropbox-sdk-python. Here is my python code:
import os
import dropbox
from dropbox.paper import ExportFormat
dbx = dropbox.Dropbox(os.getenv('DROPBOX_ACCESS_TOKEN'))
dbx.paper_docs_download_to_file('temp.md', '12345678', ExportFormat.markdown)
# The file only contains the title of the paper.
res2 = dbx.paper_docs_download('12345678', ExportFormat.markdown)
# I don't know how extract content from res2
The downloaded file only contains the title of the paper.
Thanks
jianliao I just tried this out with an account on legacy Paper and I was able to get the body of the document using paper_docs_download_to_file and ExportFormat.markdown. Can you double check that the particular document for the doc ID you're specifying has a non-empty body, e.g., on the Dropbox web site?
As for using paper_docs_download, that returns a (dropbox.paper.PaperDocExportResult, requests.models.Response), you can access the data like this, for example:
metadata, response = dbx.paper_docs_download(DOC_ID, ExportFormat.markdown) print(response.text)
- Greg-DBDropbox Staff
jianliao I just tried this out with an account on legacy Paper and I was able to get the body of the document using paper_docs_download_to_file and ExportFormat.markdown. Can you double check that the particular document for the doc ID you're specifying has a non-empty body, e.g., on the Dropbox web site?
As for using paper_docs_download, that returns a (dropbox.paper.PaperDocExportResult, requests.models.Response), you can access the data like this, for example:
metadata, response = dbx.paper_docs_download(DOC_ID, ExportFormat.markdown) print(response.text)
- ЗдравкоLegendary | Level 20
Hi jianliao,
Keep in mind that the methods you're using (and the corresponding API endpoints) are deprecated and can be used only on old accounts that are not migrated yet. Did you check the type of your account in use? Better use export functionality - it's the successor. 😉
About the result, that you don't know what is - did you take a look on docs? 🙂 Reading is not something bad!
Hope this gives direction.
- jianliaoExplorer | Level 4
I read the doc and run this line of code:
from dropbox.users import UserFeature print(dbx.users_features_get_values([UserFeature.paper_as_files]))
It return false. Unfortunately, my company account is still on legacy paper.
For below API call, I want to know how extract the content of the paper.
res2 = dbx.paper_docs_download('12345678', ExportFormat.markdown)
When I print out res2, I got this:
(PaperDocExportResult(mime_type='text/x-markdown', owner='jianliao@xxxx.com', revision=76, title='Build something cool'), <Response [200]>)
- ЗдравкоLegendary | Level 20
Try something like following:
res, stream = dbx.paper_docs_download('12345678', ExportFormat.markdown) print(f"Title: {res.title}\nOwner: {res.owner}\nMime: {res.mime_type}") print(stream.text)
Are you sure you have docs read? 🧐 Anyway...
Hope this helps.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,882 PostsLatest Activity: 11 hours agoIf 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!