Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
kobaldm
Helper I
Helper I

PowerBI-JavaScript SDK problem with Azure PowerBi embedded

Hello All,

 

I used the CLI Tool to uploaded a report to azure and genereated the correct access-token.

 

please see next post 

 

I downloaded https://github.com/Microsoft/PowerBI-JavaScript/tree/dev (it is 2.0 beta6)

 

I get the folloing error:

httpPostMessage.js:76 Uncaught TypeError: Cannot read property 'id' of undefined

 

which breaks down to 

    1. HttpPostMessage.getTrackingProperties@httpPostMessage.js:76
      WindowPostMessageProxy.onMessageReceived@windowPostMessageProxy.js:169
      WindowPostMessageProxy.windowMessageHandler@windowPostMessageProxy.js:85

 

The Server is hosting the code below in not on azure. 

Any idea what my problem could be ?

 

michael

 

 

 

 

 

 

7 REPLIES 7
kobaldm
Helper I
Helper I

i cleaned installed 2.0 beta 5 with bower. 

Now i get a 403

 

ai.0.js:1GET https://wabi-west-europe-redirect.analysis.windows.net/metadata/cluster 403 (Forbidden)XMLHttpRequest.send @ ai.0.js:1(anonymous function) @ powerbiportal.dependencies.bundle.min.js:113n @ powerbiportal.dependencies.bundle.min.js:109g @ powerbiportal.dependencies.bundle.min.js:106(anonymous function) @ powerbiportal.dependencies.bundle.min.js:140$eval @ powerbiportal.dependencies.bundle.min.js:154$digest @ powerbiportal.dependencies.bundle.min.js:152(anonymous function) @ powerbiportal.dependencies.bundle.min.js:155e @ powerbiportal.dependencies.bundle.min.js:57(anonymous function) @ powerbiportal.dependencies.bundle.min.js:60
service.ts:246 TypeError: Cannot read property 'replace' of undefined(…) []

Is this a bug on azure or is my token not correct ?

 

<!DOCTYPE html>
<html>
<head>
	<title>PowerBi clint test</title>
	<script type="text/javascript">
		function doinit(){
			//powerbi.enableAutoEmbed();
			var element = document.getElementById('myReport');
			var report = powerbi.embed(element);
			console.log("initDOne")
		}
	</script>
</head>
<body>

<div id="myReport"
	powerbi-type="report"
    powerbi-embed-url="https://embedded.powerbi.com/appTokenReportEmbed?reportId=cb1d25d3-418f.......b1da1053cb"
    powerbi-access-token="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXIiYW5hbHlzaXMud2luZG93cy5uZXQvcG93ZXJiaS9...........QiLCJ3aWQiOiIxMTJlZmZmNy0yMTNlLTQwYzktYTQ2MC0wNWRhNjFkZWQzYmEiLCJyaWQiOiJiMTIwMWE5OS0wMTAwLTRiY2UtYmQ2Yy1jOTY1NTcyYTdjMTYiLCJuYmYiOjE0Njc4ODQ3MTgsImV4cCI6MTQ2Nzg4ODMxOH0.qnewuX0EF3_EUglNFpgBIKL-fA31u7xJDnRMHzuCQfs">
	
</div>
<button onclick="doinit()">Press me to init</button>
<script src="./bower_components/powerbi-client/dist/powerbi.js"></script>
</body>
</html>

 

 

I'm doing it practically the same way. The only difference with my code is that I pass the report ID to the embed function as well, but I'm not sure if that solves it.

 

I do it in JS like this:

 

 

window.powerbi.embed($elem[0], {
   embedUrl: url,
   accessToken: token,
   id: reportId // <---- report ID
});

But you could also use the html attribute I suppose:

 

 

<div id="myReport"
	powerbi-type="report"
    powerbi-embed-url="https://embedded.powerbi.com/appTokenReportEmbed?reportId=cb1d25d3-418f.......b1da1053cb"
    powerbi-access-token="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXIiYW5hbHlzaXMud2luZG93cy5uZXQvcG93ZXJiaS9...........QiLCJ3aWQiOiIxMTJlZmZmNy0yMTNlLTQwYzktYTQ2MC0wNWRhNjFkZWQzYmEiLCJyaWQiOiJiMTIwMWE5OS0wMTAwLTRiY2UtYmQ2Yy1jOTY1NTcyYTdjMTYiLCJuYmYiOjE0Njc4ODQ3MTgsImV4cCI6MTQ2Nzg4ODMxOH0.qnewuX0EF3_EUglNFpgBIKL-fA31u7xJDnRMHzuCQfs">
    powerbi-id="cb1d...."
</div>

 

Otherwise, your token may not be valid. Make sure you create a token with the workspace collection name, workspace id and report id as claims. Then you need to generate the JSON Web Token (JWT) using one of the access keys of your workspace collection found in the Azure portal. I used the Node SDK for this.

Thank you for your reply. 

I also guess something is wrong with my token. 

I generate the token right now with the cli tool. which is more or less the same as the node sdk. 

 

create-token

Creates a Power BI app token

powerbi create-token -t <tokenType> -c <collection> -k <accessKey> -w [workspaceId] -r [reportId]

 

i used type=embed

 

Why do i need to generate JSON Web Token (JWT). And where to embed ?

 

What version of the sdk do you use ?

 

Thank you for an reply

 

michael

 

JWT is just the standard that PowerBI uses to generate a token that can be sent (you can paste your token on that site and see what is inside).

You could manually generate the JWT, but in your case the CLI tool already takes care of all that stuff and it should give you a valid token.

 

Double check all the parameters?

- tokenType should be 'embed' I think (hard to find any documentation on this...).

- collection is the workspace collection name found in Azure portal.

- accessKey is the secret key of your workspace collection also found in Azure portal.

- workspaceId is the ID of the workspace that you created using the 'create-workspaces' command.

- reportId is the ID of the report you uploaded.

 

Tokens do have an expiration date, maybe try generating a new one?

That's all I can think of...

i double checked everything. Still no luck.

 

What Version of the sdk do you use ?

 

michael

I use version 0.1.3 of the Node SDK server side to communicate with the Power BI Embedded APIs.

So I am not using the CLI tool.

 

I use a specific version of the JS client because of this issue with minification.

Found the error. Was a typo while creating the token.

 

Thank you again for helping !!!

 

michael

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.