cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right 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: 

Export legacy paper via python sdk does not work

Export legacy paper via python sdk does not work

jianliao
Explorer | Level 4

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

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox 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)

 

View solution in original post

5 Replies 5

Здравко
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. :winking_face:

About the result, that you don't know what is - did you take a look on docs? :slightly_smiling_face: Reading is not something bad!

Hope this gives direction.

jianliao
Explorer | 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]>)


 

Greg-DB
Dropbox 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

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.

jianliao
Explorer | Level 4
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    jianliao Explorer | Level 4
  • User avatar
    Здравко Legendary | Level 20
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?