How to fix the error "Embed Code Validation Failed"?
The error Embed code validation failed occurs while embedding Bold BI in your application due to the reasons listed below:
1. When the embedded application uses an older Embed secret instead of the latest one.
2. When there is a time difference between the embedded application-hosted machine and the Bold BI server-hosted machine.
Steps to be followed when an issue is due to an outdated Embed secret key:
- Go to the Settings page in the Bold BI server and select Embed option like in the below image.
3. Replace the Embed secret key in your embedded application with Embed secret key available in the downloaded JSON file.
Steps to be followed when an issue is due to time difference:
- To ensure that the problem Embed code validation failed is caused by a time discrepancy, examine the time of the Bold BI hosting machine and the embedded application hosting machine. If they are different, synchronize both machines' time to resolve the problem.
- You can also resolve this error the other way around when your Bold BI server is of version 5.3.53 or later by using the following code sample in the GetDetails API of the embedded application.
public string GetDetails([FromBody] object embedQuerString) { var embedClass = Newtonsoft.Json.JsonConvert.DeserializeObject<EmbedClass>(embedQuerString.ToString()); var embedQuery = embedClass.embedQuerString; embedQuery += "&embed_user_email=" + EmbedProperties.UserEmail; //To set the embed_server_timestamp to overcome the EmbedCodeValidation failing while different timezone using a client application. double timeStamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; embedQuery += "&embed_server_timestamp=" + timeStamp; var embedDetailsUrl = "/embed/authorize?" + embedQuery + "&embed_signature=" + GetSignatureUrl(embedQuery); using (var client = new HttpClient()) { client.BaseAddress = new Uri(embedClass.dashboardServerApiUrl); client.DefaultRequestHeaders.Accept.Clear(); var result = client.GetAsync(embedClass.dashboardServerApiUrl + embedDetailsUrl).Result; string resultContent = result.Content.ReadAsStringAsync().Result; return resultContent; } } |
Related links: