Articles in this section
Category / Section

Passing Large-Size Filter Parameter Through the "embed_datasource_filter" Query Parameter for Filtering

Published:

In certain scenarios, you may need to pass large-size filter parameter through the embed_datasource_filter query parameter for filtering. This can be achieved by utilizing the POST type REST API request to Bold BI in the authorization server API of the embedded application. This API allows you to pass multiple parameters, including hundreds of values, without causing any issues.

The existing API request is of the type GET which also can include the larger values in the query parameter. However, for passing larger-size data, a POST-type API request is more suitable.

Here is the syntax to utilize the POST-type API request in C#:


        [HttpPost]
        [Route("AuthorizationServer")]
        public string AuthorizationServer([FromBody] object embedQuerString)
        {
            var embedClass = Newtonsoft.Json.JsonConvert.DeserializeObject<embedclass>(embedQuerString.ToString());
            var embedQuery = embedClass.embedQuerString;
           double timeStamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
            embedQuery += "&embed_server_timestamp=" + timeStamp;
            embedQuery += "&embed_user_email=" + GlobalAppSettings.EmbedDetails.UserEmail+"&embed_datasource_filter=[{&&Parameter=IN(value1, value2, …, valueN)}]”;
            var embedDetailsUrl = embedQuery + "&embed_signature=" + GetSignatureUrl(embedQuery);

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(embedClass.dashboardServerApiUrl);
                client.DefaultRequestHeaders.Accept.Clear();
                var result = client.PostAsync(embedClass.dashboardServerApiUrl + "/embed/authorize", new StringContent(JsonConvert.SerializeObject(embedDetailsUrl), System.Text.Encoding.UTF8, "application/json")).Result;
                string resultContent = result.Content.ReadAsStringAsync().Result;
                return resultContent;
            }

        }

In the above code, embedQuery is the query string from Embed SDK that you want to pass to the server. embed_user_email is the email of the user who has appropriate permission for the dashboard to be rendered, and embed_datasource_filter is the filter which holds n number of the parameters that you want to apply to the dashboards. The PostAsync method is used to send a POST request to the specified URI as an asynchronous operation.

References

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
SM
Written by Soundarya Mani Meharan
Updated:
Comments (0)
Please  to leave a comment
Access denied
Access denied