Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

jianliao's avatar
jianliao
Explorer | Level 4
2 years ago
Solved

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)

     

5 Replies

Replies have been turned off for this discussion
  • Здравко's avatar
    Здравко
    Legendary | Level 20
    2 years ago

    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.

  • jianliao's avatar
    jianliao
    Explorer | Level 4
    2 years ago

    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's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    2 years ago

    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)

     

  • Здравко's avatar
    Здравко
    Legendary | Level 20
    2 years ago

    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

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!