Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I followed the instructions to embedded QnA, but getting following error:
Uncaught Error: Attempted to embed component of type: qna but did not find any matching component. Please verify the type you specified is intended.
at Service.embedNew (service.ts:235)
at Service.embed (service.ts:210)
Error is thrown in below function in service.ts:
/**
* Given a configuration based on a Power BI element, saves the component instance that reference the element for later lookup.
*
* @private
* @param {IPowerBiElement} element
* @param {embed.IEmbedConfiguration} config
* @returns {embed.Embed}
*/
private embedNew(element: IPowerBiElement, config: embed.IEmbedConfiguration): embed.Embed {
const componentType = config.type || element.getAttribute(embed.Embed.typeAttribute);
if (!componentType) {
throw new Error(`Attempted to embed using config ${JSON.stringify(config)} on element ${element.outerHTML}, but could not determine what type of component to embed. You must specify a type in the configuration or as an attribute such as '${embed.Embed.typeAttribute}="${Report.type.toLowerCase()}"'.`);
}
// Saves the type as part of the configuration so that it can be referenced later at a known location.
config.type = componentType;
const Component = utils.find(component => componentType === component.type.toLowerCase(), Service.components);
if (!Component) {
throw new Error(`Attempted to embed component of type: ${componentType} but did not find any matching component. Please verify the type you specified is intended.`);
}
const component = new Component(this, element, config);
element.powerBiEmbed = component;
this.addOrOverwriteEmbed(component, element);
return component;
}
Really appreciate any help to resolve this.
Thank you
Dheeraj
Solved! Go to Solution.
Is your version of powerbi.js up to date? Could it be you are using an older version of powerbi.js before the qna support was added?
The current version is v2.6.5
Here is the basic client-side code you need. Note you must include an array of dataset IDs. The irony here is that you can only pass a single dataset ID in the array as the support for embedding the QnA experience with two or more datasets is not there yet.
// Get data required for embedding var datasetId = "5c82edbf-46a1-48f3-b337-3ef12c69a94b"; var embedUrl = "https://app.powerbi.com/qnaEmbed?groupId=54afb565-3935-47e1-9a89-67e48a78ca45"; var accessToken = "H4sIAAAAAAAEACWWxa7FCnJF_-VNHclMkXpgPGbmmZmZHeXfc9M93zWopdpL9T__WOk7zGnxz3__U8EzQUY04RjVWIYpMwKv6NR4U7FNHbCV1qbNUbN48dbg0PSQsty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Dzaxg52g3KkfYWoAytE-vVLcU1btqEMbwrs4kF_rbejKNLzXS22mfyZ85bpQr3v_71z3_9w23vcsxq-f69OdyA6KjeMBNabDMmT7iAyQmzoed7v_P-Auhy2tdWlD7Xc4_TWz7O13Q2AQvHA6e0Bs3utK6ZpyfgPGF2rOfGbPac5n45hJf7_OKxyevbJJiAc_vUR-Gf73wUBqeKxhVIH2FPScz01ZEKuavEvHlcFbuFlCJBpPbpjBTGsFrFcCDtODIs9ng_i31ob21iXscTnuvJTHmU4irKPOvx0aXjzKLRj1vpd6KsUaLPqnp6uN23fGPleA6SWW_Po5L4eUJ3r5m4VdCSv5mRVJ1tQe_XWPKt7xryekToZzRWKdgENUxNFG0oRCepVgkLl0jpdr7qaIWaq9oaEFbXFNXtM5zNSnL2fzC_S1NucvBHOX8Vouyh159Ck1mRE6l1WKz_nXLbekqPcyv_YiWs9EqC7M55Wj8KDoXmBG_X3g8SGIrIAYJ3j3eOsTmcJn5CBhOh1vINhSpffWxToBESoWwUuMtTmRTE9kQI4IzJdHaLGb3llrhUPjRZUCXObVtgl7xDdVHr9ZvuoN7y86Pw5Ei3QTjlG8iEKbV1Wy0aoMNcUvcV__l6c6w873nBP7UK9SDmvwenRUn8fHOYf32OnhF0x28bBdqZR_aZWMncXxw_-hL4qDZYGOW5XM7HjmKuo6Ut4xPwpwOxoHzgqU9HlFHvxh8Zj6IL8c9i91XS17I8vDeD1lDjffrAgqHEfsPz6Rv9OyqRO32Euxo_42Gf_MWRNKlT3CEZSyBqFEnH_9_8__4fQpW8SNoLAAA="; // Get models object to access enums for embed configuration var models = window['powerbi-client'].models; var config = { type: 'qna', tokenType: models.TokenType.Embed, accessToken: accessToken, embedUrl: embedUrl , datasetIds: [ datasetId ], viewMode: models.QnaMode.Interactive //, question: "What is sales revenue by quarter and sales region as stacked area chart" }; // Get a reference to the embedded report HTML element var embedContainer = document.getElementById('embedContainer'); // Embed the report and display it within the div container. var embeddedObject = powerbi.embed(embedContainer, config);
Also, if you are using the app-owns-data model with embed tokens, you must create the embed token by passing the target dataset ID.
public static QnaEmbeddingData GetQnaEmbeddingData() { PowerBIClient pbiClient = GetPowerBiClient(); var dataset = pbiClient.Datasets.GetDatasetByIdInGroup(workspaceId, datasetId); string embedUrl = "https://app.powerbi.com/qnaEmbed?groupId=" + workspaceId; string datasetID = dataset.Id; GenerateTokenRequest generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view"); string embedToken = pbiClient.Datasets.GenerateTokenInGroup(workspaceId, dataset.Id, generateTokenRequestParameters).Token; return new QnaEmbeddingData { datasetId = datasetId, embedUrl = embedUrl, accessToken = embedToken }; }
Hello,
I am trying to explore the functionality of Power BI Q&A. I need to perform Q&A on 2 or more datasets in the Power BI workspace. However, I am unable to do so.
Based on the comment "Here is the basic client-side code you need. Note you must include an array of dataset IDs. The irony here is that you can only pass a single dataset ID in the array as the support for embedding the QnA experience with two or more datasets is not there yet.", could you let me know if the feature for embedding QnA experience for multiple datasets is implemented in the Power BI embedded Service?
Thanks.
Thank you Ted Pattison for the reply.
Yes, am using app-owns-data model with embed tokens and the code you provided was helpful.
Below is the client-side code which throws the error I reported initially.
@{ ViewData["Title"] = "QandA"; } <script src="~/js/powerbi.js"></script> <div id="qnaContainer" class="body-content" style="float:left;width:100%;display:block"></div> <script> // Get data required for embedding var datasetId = "5c82edbf-46a1-48f3-b337-3ef12c69a94b"; var embedUrl = "https://app.powerbi.com/qnaEmbed?groupId=54afb565-3935-47e1-9a89-67e48a78ca45"; var accessToken = "H4sIAAAAAAAEACWWxa7FCnJF_-VNHclMkXpgPGbmmZmZHeXfc9M93zWopdpL9T__WOk7zGnxz3__U8EzQUY04RjVWIYpMwKv6NR4U7FNHbCV1qbNUbN48dbg0PSQstyrkBXV25ahPKxc-7mfWFQhpoaJU0lA-wLlrOKr0lGwQmN-nLTffMaLJfVoh9M6ySHrgWtsEduTnVw6rAXR7tIuAhDpRhpqK5CzaL8Ex3YB9NS4168EEIrlYW1HfqJRkNRDoDs0N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QvHA6e0Bs3utK6ZpyfgPGF2rOfGbPac5n45hJf7_OKxyevbJJiAc_vUR-Gf73wUBqeKxhVIH2FPScz01ZEKuavEvHlcFbuFlCJBpPbpjBTGsFrFcCDtODIs9ng_i31ob21iXscTnuvJTHmU4irKPOvx0aXjzKLRj1vpd6KsUaLPqnp6uN23fGPleA6SWW_Po5L4eUJ3r5m4VdCSv5mRVJ1tQe_XWPKt7xryekToZzRWKdgENUxNFG0oRCepVgkLl0jpdr7qaIWaq9oaEFbXFNXtM5zNSnL2fzC_S1NucvBHOX8Vouyh159Ck1mRE6l1WKz_nXLbekqPcyv_YiWs9EqC7M55Wj8KDoXmBG_X3g8SGIrIAYJ3j3eOsTmcJn5CBhOh1vINhSpffWxToBESoWwUuMtTmRTE9kQI4IzJdHaLGb3llrhUPjRZUCXObVtgl7xDdVHr9ZvuoN7y86Pw5Ei3QTjlG8iEKbV1Wy0aoMNcUvcV__l6c6w873nBP7UK9SDmvwenRUn8fHOYf32OnhF0x28bBdqZR_aZWMncXxw_-hL4qDZYGOW5XM7HjmKuo6Ut4xPwpwOxoHzgqU9HlFHvxh8Zj6IL8c9i91XS17I8vDeD1lDjffrAgqHEfsPz6Rv9OyqRO32Euxo_42Gf_MWRNKlT3CEZSyBqFEnH_9_8__4fQpW8SNoLAAA="; // Get models object to access enums for embed configuration var models = window['powerbi-client'].models; var config = { type: 'qna', tokenType: models.TokenType.Embed, accessToken: accessToken, embedUrl: embedUrl, datasetIds: [datasetId], viewMode: 1
//models.QnAMode.Interactive //, question: "What is sales revenue by quarter and sales region as stacked area chart" }; // Get a reference to the embedded report HTML element var embedContainer = document.getElementById('qnaContainer'); // Embed the report and display it within the div container. var embeddedObject = powerbi.embed(embedContainer, config); </script>
Error:
Uncaught Error: Attempted to embed component of type: qna but did not find any matching component. Please verify the type you specified is intended.
at Service.embedNew (service.ts:235)
at Service.embed (service.ts:210)
Embedding of Reports and Dashboards work fine. Its just the QnA which has this issue, and makes me think if I need to include anything more than powerbi.js ?
<script src="~/js/powerbi.js"></script>
Thank you.
Dheeraj
Is your version of powerbi.js up to date? Could it be you are using an older version of powerbi.js before the qna support was added?
The current version is v2.6.5
That was it, I was always using Nuget to update the PowerBI.Javascript to latest but didn't check the actual powerbi.js which was v2.3.1. Thank you!
Now QnA object seems to render but there is an 401 - Unauthorized.
Are you supplying server-side code to generate an access token like this?
GenerateTokenRequest generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view"); string embedToken = pbiClient.Datasets.GenerateTokenInGroup(workspaceId, dataset.Id, generateTokenRequestParameters).Token;
Make sure the dataset id in this code which generates the embed token matches is the same dataset id that you are using in the client-side embed configuration to display the Q&A experience. That would be my first guess at what is wrong.
Yes, I do supply server-side code to generate access:
var tokenResponse = await client.Datasets.GenerateTokenInGroupAsync(firstPBIGroupID, dataset.Id,
generateTokenRequestParameters);
// Generate Embed Configuration.
result.EmbedToken = tokenResponse;
result.EmbedUrl = "https://app.powerbi.com/qnaEmbed?groupId=" + firstPBIGroupID;
result.Id = dataset.Id;
return View(result);
client-side:
// Read embed application token from Model var accessToken = "@Model.EmbedToken.Token"; // Read embed URL from Model var embedUrl = "@Html.Raw(Model.EmbedUrl)"; // Read dataset Id from Model var embedDatasetId = "@Model.Id"; // Get models. models contains enums that can be used. var models = window['powerbi-client'].models; // Embed configuration used to describe the what and how to embed. var config = { type: 'qna', tokenType: models.TokenType.Embed, accessToken: accessToken, embedUrl: embedUrl, datasetIds: [embedDatasetId], viewMode: models.QnaMode.Interactive }; // Get a reference to the embedded Q&A HTML element var qnaContainer = $('#qnaContainer')[0]; // Embed the QNA and display it within the div container. var qna = powerbi.embed(qnaContainer, config);
I tried different datasets but all have the same issue, I even made sure the powerbi pro-user who is used for access is given "Read and Reshare" access.
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
41 | |
4 | |
4 | |
3 | |
3 |