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:
- run a report using the post command of https://modeanalytics.com/api/<account>/reports/<report>/runs
- wait for the report to finish (while loop checking the run state) using https://modeanalytics.com/api/<account>/reports/report/runs/<run>
- 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 https://forum.modeanalytics.com/t/18m91b/ftp-report-uploads ; 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?
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 `_links.download.href`
Hope that helps!Reply