export via rest api

I am trying to export a dashboard to an image via the rest API.

Of course, snooping what happens when I do it via the web interface is the way to go, but I am a bit stumped here (3k+ lines in the json payload and an unholy amount of GUID do not help).

In short:

  • my dashboard has 8 metric sets, and the json seems to set parameters for each of them. This seems very brittle to me
  • my dashboard has one view parameter, bound to the proper slicers on metric sets. That is the one I want to set once and for all, as can be done via the url https://www.dundas.com/Support/developer/samples/integration/pass-parameter-values-via-query-string In my example below, with the viewparameter lname I can add $lname=bdu to the URL to filter the dashboard automatically.

I know the GUID of the image provider (variable provider_id), of my dashboard (variable dash_id) and of the view parameter (param_id). I thought that the following payload would be enough:

"__classType": "dundas.export.ExportRequest",
"isLegacyExport": True,
"providerId": provider_id,
"viewId": dash_id,
"ViewParameters": [{
    "__classType": "dundas.view.ViewParameter",
    "id": param_id,
    "parameterValue": {
         "__classType": "dundas.data.CollectionMemberValue",
         "isInverted": false,
         "parameterId": "0c84d309-6704-4798-a6a5-9a40cdd0bc8c", # I have no clue where this one comes from, cut & paste from the payload
         "parameterValueType": "CollectionMember",
         "values": [{
                "__classType": "dundas.data.MemberValue",
                "hierarchyUniqueName": "lname", 
                 "levelDepth": 0,
                 "levelUniqueName": "lname",
                 "memberKind": "Regular",
                 "uniqueName": "bdu.lname"
            }]
        }
}],

But well, of course it isn’t enough otherwise I wouldn’t ask here :slight_smile:
There is a as well a filter element, with yet another id, bound to the view parameter but I don’t think this one is relevant.

What could I be missing?
Thanks,

We have a sample here on exporting with parameters:

https://www.dundas.com/support/developer/script-library/export/exporting-with-parameters

Generally speaking, with regards to exports there are two types of request object – dundas.export.ExportRequest and dundas.data.Request. Both of them have a parameterValues property.

https://www.dundas.com/support/api-docs/js/#API%20Reference/dundas/export/ExportRequest/Properties/parameterValues.html

https://www.dundas.com/support/api-docs/js/#API%20Reference/dundas/data/Request/Properties/parameterValues.html

However it is the data request object you will want to append the parameter values to. The property in the export request object is to set any parameters that are defined for the specific export plugin. In layman’s terms, these are the settings/checkboxes you get when exporting through the UI.

Make sure to use the data request object on this one.

Thanks Christian,

The issue with this example is that it is a Javascript example and I need to use pure REST API. Furthermore it looks like I need to set the parameter for all relevant metric sets.

This means, if I understand it well, that:

  • I need to somehow, via the rest API find all metric sets within my dashboard
    – but only the relevant ones, so I need a way to filter them out
  • if I change the dashboard, I need to update the export call to match the dashboard implementation
  • I need to add a datarequest parameter per metric set
  • I don’t even want to think about dashboards embedding other dashboards

This is exactly the point of the view parameter: it has all relevant bindings already built in, and it can be used in the URL when looking at a dashboard on a screen.

This is what I am looking for: setting the view parameter via the export rest call to not need to know the internal implementation of my dashboard.

Is there no way at all to do this?

We managed to resolve this one offline. This is just for anyone else who may be curious.

The request body that gets sent with the /Export call is almost identical in structure to its JavaScript equivalent, as you can see here:

https://www.dundas.com/support/api-docs/NET/Content/html/T_Dundas_BI_WebApi_Models_ViewData.htm

As far as retrieving this object goes, you can send the GET request to the /Dashboard/{id} endpoint, which will send you a viewData object in the response body.

https://www.dundas.com/support/api-docs/rest/#Dundas%20BI%20REST%20API%20Reference/Dashboard/{id}/GET.html

At that point, you could modify the ViewParameters property as you see fit and then send that entire ViewData object to its corresponding property in the /Export endpoint request body.

Hi @christianp

I’m currently speaking to Insight support about this but not getting very far.

I have the exact same issue - I’m trying to set the viewParams when exporting a Report via the REST Web-Api.

My issue is when I call GET /Report/{id} I do not receive anything in the ViewData property.

Has something changed in the API since 2019?

Our Dundas version is 10.0.0.1006-w

Apologies - typo in my post, it’s that the viewParameters are empty in the ViewData object that’s returned from GET /Report/{id}

If I add my parameter into the viewData…viewParameters array, I am returned a blank 1 page PDF file.

If I don’t set the viewData in the Export request object I receive the PDF however as there’s no viewParams being sent, I just receive the default values.

Hi Alasdair - Sorry that you didn’t get any replies here earlier, insightsoftware is in the process of migrating from these forums. We don’t believe the API has changed, but if you didn’t solve this problem already please contact support again, because we should be able to solve it with feedback from my department if needed.