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
RestTemplate
class to create a new instance ofRestTemplate
.
RestTemplate restTemplate = new RestTemplate();
- Create a new instance of
DefaultUriBuilderFactory
and set its encoding mode toNONE
. This will avoid encoding the query parameter, which is already encoded using theGetSignatureUrl
method.
DefaultUriBuilderFactory defaultUriBuilderFactory = new DefaultUriBuilderFactory();
defaultUriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE);
- Avoid using hardcoded values for the
embedQuery
in thegetDetails
method. Instead, use theembedQueryString
parameter 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).