can't get pdf export to give me a file

I'm developing a python script that is calling the mode API.  The main purpose of the script is the following:

  1. run a report using the post command of<account>/reports/<report>/runs
  2. wait for the report to finish (while loop checking the run state) using<account>/reports/report/runs/<run>
  3. when the run is done, I want to get the PDF rendition of the report. I've implemented bits of the sample script from this thread ; however, when I get the pdf export url, it always returns the state 'new' below. Is there some addition setting or a different method required to get the pdf rendition?

    "state": "new",
    "created_at": null,
    "content_length": null,
    "stale": false,
    "filename": null,
    "_links": {
        "self": {
            "href": "/api/account/reports/442fea1af25d/exports/runs/fba24d438923/pdf.pdf"

3replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Hi Paul Kaisharis - thanks for writing in. The answer to your question is both undocumented and non-obvious - apologies that it's a bit opaque!

    Whenever a new report run completes and a PDF has not already been generated (either via the Mode UI or a scheduled email job with an attached PDF), you will see the type of response listed above  (with `state: new`) when you hit endpoint located at `_links.pdf_export.href' located in the report run endpoint.

    Therefore, there are a few additional steps to perform after the ones you outlined. To complete the process:

    4) Kick off a PDF generation job on our end by hitting that `pdf_export` endpoint with a POST. If successful, the response will include `state: enqueued`

    5) Poll the same endpoint with a GET occasionally (the job usually takes a few seconds to complete) until you get `state: completed`

    6) Once completed, the PDF download link will be available in ``

    Hope that helps!

  • great, thx Jonathan Krangel .  i ended up using the 'preview' image (our reports are typically one pagers) and rendering that to pdf, but good to know there is a way to get to the pdf as well.  i also ended up using the csv data to generate an excel output, as an aside. 

  • Jonathan Krangel Do these extra steps need to happen on the server side when using white label embed. Client side requests to the endpoint doesn't seem to work. I keep running into "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at"

Like Follow
  • Status Answered
  • 7 mths agoLast active
  • 3Replies
  • 615Views
  • 3 Following