GitHub user billbelanger edited a comment on the discussion: Scheduled reports
with filters
Thanks @dosu that lead us in the right direction. To follow up and provide a
fuller answer, for anyone else coming across this issue, we were able to
generate a filter'd report using the API for the create (`POST
/api/v1/report`). In order to do so, we had to do the following:
First, we had to get the list of native filters for the dashboard: `GET
/api/v1/dashboard/:id`, which provided us with this in the response:
```json
{
"result": {
...
"json_metadata": "<stringified json>"
}
}
```
If we unpack the `json_metadata`, we find (apologize for the verbosity here,
but I've stripped away most of what wasn't important):
```json
{
"native_filter_configuration": [
{
"id": "NATIVE_FILTER-abcdefg",
"name": "<Human readable filter name>",
"filterType": "filter_select",
"targets": [
{ "column": { "name": "<column name>" }, "datasetId": 01234 }
],
"defaultDataMask": {
"extraFormData": {
"filters": [
{ "col": "<column name>", "op": "IN", "val": ["<default filter
value>"] }
],
"filterState": {
"validateMessage": false,
"validateStatus": false,
"label": "<default filter value>",
"value": ["<default filter value>"]
}
},
"type": "NATIVE_FILTER"
}
]
}
```
Taking those values, we can now construct our API call (`POST /api/v1/report`)
to create the filter'd report. The important part here is the `extra` field:
```json
{
"active": true,
"creation_method": "alerts_reports",
"extra": {
"dashboard": {
"nativeFilters": [
{
"nativeFilterId": "NATIVE_FILTER-abcdefg",
"columnName": "<column name>",
"filterType": "filter_select",
"filterValues": ["<filter value I want>"]
}
]
}
},
...
}
```
I tested this a couple of times and it worked in our DEV environment with one
or multiple filters. No need for the `dataMask` mentioned by Dosu so far as I
could tell. Maybe it does something I'm unaware of.
This really felt like it maybe could be documented somewhere as I didn't think
this was too outlandish a request. I'm happy to write up the doc / help file if
someone would like to point me to where it belongs, or if they could tell me
why the `dataMask` is important, I could include that too.
GitHub link:
https://github.com/apache/superset/discussions/42544#discussioncomment-17827293
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]