Is there a way to programmatically export an insig...
# gooddata-platform
e
Is there a way to programmatically export an insight to xlsx and/or csv with the API? (Same result as clicking Export To… in the Analyze view)
j
Hello Evan, yes there is. The same functionality is exposed in our API as well. Please see https://help.gooddata.com/doc/enterprise/en/dashboards-and-insights/reports/working-with-reports/exporting-raw-report-data#ExportingRawReportData-Exportingthedata, Through the raw data export API. For more information, see API Reference.
e
so I found the part of the api docs for “Export an insight” but it talks about manually getting an
executionResult
uri out of the devtools network tab, which wouldn’t work for a programmatic solution. Does the
InsightView
React component have a way of grabbing this execution result or am I going to have to resort to a network interceptor?
j
You can get the
executionResult
URI out of of the devtools only to quickly try out the
exportResult
endpoint and see how it works.
If you want to get
executionResult
programmatically, simply fire the
executeAfm
request first, grab the
executionResult
programmatically and then fire the
exportResult
.
e
ok
is there an easy way to get the afm definition out of an InsightView?
j
There is something like executeByReference that does exactly what you're looking for, but I can't seem to find it atm 😞
I asked our eng team, but they currently have 10pm so I might get back to you tomorrow. Thanks for your patience!
Evan, I found a
onExportReady
property on the
InsightView
component here: https://sdk.gooddata.com/gooddata-ui/docs/visualization_component.html
Please see if https://sdk.gooddata.com/gooddata-ui/docs/on_export_ready.html isn't what you're looking for. It seems it could simplify the flow you are trying to achieve.
e
ah that looks like exactly what I wanted, thank you!
👍 1
j
Cool! Let me know if you need anything else 🙂
👍 1