Category / Section
Resolving Embed Code Validation Failed Error in Java
Published:
When embedding a dashboard using Java (Spring Boot), you may encounter a 400 Bad Request error with the message “Embed code validation failed.” This issue is likely due to the encoded value in the embed signature parameter value. To resolve this problem, pass the URL value without the encoded format.
Solution
- Use the
RestTemplateclass to create a new instance ofRestTemplate.
RestTemplate restTemplate = new RestTemplate();
- Create a new instance of
DefaultUriBuilderFactoryand set its encoding mode toNONE. This will avoid encoding the query parameter, which is already encoded using theGetSignatureUrlmethod.
DefaultUriBuilderFactory defaultUriBuilderFactory = new DefaultUriBuilderFactory();
defaultUriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE);
- Avoid using hardcoded values for the
embedQueryin thegetDetailsmethod. Instead, use theembedQueryStringparameter from the Embed SDK.
By following these steps, you should be able to resolve the “Embed code validation failed” error when embedding a dashboard using Java (Spring Boot).