2 weeks ago
When I pass multiple filters using "external_value" while embedding the Databricks dashboard, I encounter an error stating that the dashboard ID is missing.
For example, passing a single filter works fine, but when I pass multiple filter values (such as "org_id" and "user_id"), the request fails with this error.
Could you please clarify:
1. Is there a supported way to pass multiple filters through "external_value"?
2. Is there any specific JSON format or configuration required?
3. Are there any limitations when passing multiple external filter values along with the dashboard ID?
If possible, could you share a working example of passing multiple filters in an embedded dashboard?
Example:
var externalValue = JsonSerializer.Serialize(new
{
org_id = "1001",
user_id = "2001"
});
var url = $"{workspaceUrl}/api/2.0/lakeview/dashboards/{dashboardId}/published/tokeninfo";
var builder = new UriBuilder(url);
var query = System.Web.HttpUtility.ParseQueryString("");
query["external_viewer_id"] = "user_123";
query["external_value"] = externalValue;
builder.Query = query.ToString();
var response = await httpClient.GetAsync(builder.Uri);
a week ago
Hi @AjayKumarM, adding to what @data_pulse found. Since /tokeninfo accepts the JSON fine, I'd look at the next call, where you swap the response for the scoped token. That's usually where a JSON-shaped value goes wrong.
In the documented flow, step 3 takes everything /tokeninfo returns, turns authorization_details back into a JSON string, adds grant_type=client_credentials, and posts all of it form-encoded to /oidc/v1/token. The custom_claim field in that response holds the dashboard ID together with your external values. If that field gets changed on the way (re-serialized, split on a comma or &, or posted without URL encoding), the scoped token ends up without the dashboard ID, and that's the error you're seeing. A plain value like 1001 survives sloppy handling. A JSON object full of quotes, colons and commas usually doesn't.
In C#, the safest way is to let FormUrlEncodedContent encode the body and pass the fields through untouched:
using var tokenInfoDoc = JsonDocument.Parse(await tokenInfoResponse.Content.ReadAsStringAsync());
var form = new List<KeyValuePair<string, string>>
{
new("grant_type", "client_credentials")
};
foreach (var prop in tokenInfoDoc.RootElement.EnumerateObject())
{
// authorization_details must go back as a JSON string; everything else as-is
var value = prop.Name == "authorization_details"
? prop.Value.GetRawText()
: (prop.Value.ValueKind == JsonValueKind.String ? prop.Value.GetString()! : prop.Value.GetRawText());
form.Add(new(prop.Name, value));
}
var req = new HttpRequestMessage(HttpMethod.Post, $"{workspaceUrl}/oidc/v1/token?o={workspaceId}")
{
Content = new FormUrlEncodedContent(form)
};
req.Headers.Authorization = new AuthenticationHeaderValue("Basic", basicAuth);
var scoped = await httpClient.SendAsync(req);Don't build the body by joining strings, and don't parse and rebuild custom_claim yourself.
On your three questions:
SELECT * FROM sales WHERE org_id = get_json_object(__aibi_external_value, '$.org_id') AND user_id = get_json_object(__aibi_external_value, '$.user_id')
If you'd rather keep it simple, send a delimited string like 1001|2001 and use split_part(__aibi_external_value, '|', 1) and split_part(__aibi_external_value, '|', 2). 3. external_viewer_id and external_value together can't be more than 1 KB. Also keep personal data out of external_viewer_id, since that one ends up in the audit logs.
If it still fails after that change, could you say whether the error comes back from /oidc/v1/token or later when the dashboard renders? And try the delimited string version once. If that works and the JSON doesn't, it's the encoding for sure.
Docs: https://docs.databricks.com/aws/en/dashboards/share/embedding/external-embed
a week ago
2 weeks ago
Hi @AjayKumarM
I ran a few checks against a published dashboard using both the Databricks CLI and REST API. Here are my observations on your questions.
1. external_value is documented as a single string parameter, rather than a collection of dashboard filter parameters.
I tested single values, comma-separated values, colon-separated values, JSON arrays and a JSON object. All /published/tokeninfo requests succeeded.
For multiple region values, one possible approach is to pass a comma-separated string and interpret it in the dashboard dataset SQL:
WHERE array_contains(split(__aibi_external_value, ','), region)This is a suggested approach and any access restrictions should be based on authenticated viewer entitlements.
2. The documentation doesn't specify a special multi-filter JSON schema for external_value.
I also tested a JSON object containing org_id and user_id. The token-info API accepted it, and the returned custom_claim preserved the input and expected dashboard UUID.
However, I couldn't validate the complete scoped OAuth and browser-rendering flow.
3.The documented combined size limit for external_value and external_viewer_id is 1 KB.
I couldn't reproduce the dashboard ID error at the /published/tokeninfo stage. It would be worth checking whether the error occurs during scoped-token generation (/oidc/v1/token) or dashboard rendering and whether the returned custom_claim is forwarded unchanged.
Could you share which step fails and any error details? Happy to help investigate further.
a week ago
Thank you so much this solution now it works with comma separated.
a week ago
Hi @AjayKumarM, adding to what @data_pulse found. Since /tokeninfo accepts the JSON fine, I'd look at the next call, where you swap the response for the scoped token. That's usually where a JSON-shaped value goes wrong.
In the documented flow, step 3 takes everything /tokeninfo returns, turns authorization_details back into a JSON string, adds grant_type=client_credentials, and posts all of it form-encoded to /oidc/v1/token. The custom_claim field in that response holds the dashboard ID together with your external values. If that field gets changed on the way (re-serialized, split on a comma or &, or posted without URL encoding), the scoped token ends up without the dashboard ID, and that's the error you're seeing. A plain value like 1001 survives sloppy handling. A JSON object full of quotes, colons and commas usually doesn't.
In C#, the safest way is to let FormUrlEncodedContent encode the body and pass the fields through untouched:
using var tokenInfoDoc = JsonDocument.Parse(await tokenInfoResponse.Content.ReadAsStringAsync());
var form = new List<KeyValuePair<string, string>>
{
new("grant_type", "client_credentials")
};
foreach (var prop in tokenInfoDoc.RootElement.EnumerateObject())
{
// authorization_details must go back as a JSON string; everything else as-is
var value = prop.Name == "authorization_details"
? prop.Value.GetRawText()
: (prop.Value.ValueKind == JsonValueKind.String ? prop.Value.GetString()! : prop.Value.GetRawText());
form.Add(new(prop.Name, value));
}
var req = new HttpRequestMessage(HttpMethod.Post, $"{workspaceUrl}/oidc/v1/token?o={workspaceId}")
{
Content = new FormUrlEncodedContent(form)
};
req.Headers.Authorization = new AuthenticationHeaderValue("Basic", basicAuth);
var scoped = await httpClient.SendAsync(req);Don't build the body by joining strings, and don't parse and rebuild custom_claim yourself.
On your three questions:
SELECT * FROM sales WHERE org_id = get_json_object(__aibi_external_value, '$.org_id') AND user_id = get_json_object(__aibi_external_value, '$.user_id')
If you'd rather keep it simple, send a delimited string like 1001|2001 and use split_part(__aibi_external_value, '|', 1) and split_part(__aibi_external_value, '|', 2). 3. external_viewer_id and external_value together can't be more than 1 KB. Also keep personal data out of external_viewer_id, since that one ends up in the audit logs.
If it still fails after that change, could you say whether the error comes back from /oidc/v1/token or later when the dashboard renders? And try the delimited string version once. If that works and the JSON doesn't, it's the encoding for sure.
Docs: https://docs.databricks.com/aws/en/dashboards/share/embedding/external-embed