How to pass a parameter to Web API connector when view and embedding a dashboard
You can pass the Dashboard parameter value to the value of the Web API URL parameter, POST Parameters, or Headers. Please follow these steps:
-
Firstly, create the Dashboard parameter by following the steps outlined in section.
-
Choose a Web API data connection in the connection panel to create a web data source, and enter the required URL with the necessary parameter name as displayed in the following screenshot.
-
Now, type the
@
symbol near the parameter in the query string, and you will see the list of dashboard parameters from the data sources that have been added to your dashboard. From that list, choose the required parameter.
-
If the data source (which contains the dashboard parameter) is not currently in your dashboard or if you are creating a data source from the data source listing page, you can use the following syntax to incorporate the dashboard parameter in your web API wherever needed.
Syntax: @{{:DataSourceName.ParameterName}}
-
After configuring the dashboard parameters and completing the dashboard design, you can publish the dashboard to the server.
-
When you view the dashboard on the server, you can modify the value of the dashboard parameter if necessary. To modify the value, click on the icon highlighted below, and you will see the dashboard parameter pop-up window. Through this window, you can make changes to the parameter value.
-
When you embed a dashboard into your application and would like to change the parameters’ values based on the user, as shown in the screenshot below, you can pass the dashboard parameter values as mentioned in this section. You can also find the syntax for passing the parameter values as follows:
Syntax: embedQuerString += "&embed_user_email=xxx@domain.com" + "&embed_datasource_filter=" + "[{&&ParameterName=Value&ParameterName=Value}]";
Also, find the screenshot of the sample code below.
A dashboard will be rendered based on the passed parameter values, as shown in the following screenshot.
Here, &&
indicates the Dashboard parameter and &
indicates the URL parameter. Therefore, the web API connection will be changed based on the parameter value passed through the query string.