Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
Hi,
My goal is to generate an embedToken to be able to have a firm connection with PBI Service. I want to display the PBI dashboard at our Angualar app. Currently I'm using PBI Service, the tiral version. I'm also an administrator of the workspace where the dashboard is.
I've tried to generate the token with AAD method, it worked but (as mentioned) need something firm/stable.
My limitation is to create MS Entra ID.
I have went through a yt channel of Guyinacube -> Power BI Embed Token Using Powershell (youtube.com)
Thought it is going to be super easy, but in the end I can't generate the token as Adam does.
Here's my script:
# JSON body (use double quotes for keys and values)
# $body = "{ `accessLevel`: `View` }"
$body = "{ `"accessLevel`": `"View`" }"
# Invoke the REST API
$response = Invoke-PowerBIRestMethod -Url $url -Body $body -Method Post
# Parse the response
$json = $response | ConvertFrom-Json
$json.token
Naturally (as it was covered at the yt video) I first run "Login-PowerBI" command which restul with a success.
Environment : Public
TenantId : eaad02fb-2df7-422b-a3ga-3d8f671ebb86
UserName : jnowak@you.com
When I run the main piece of script to return me the token, the output shows:
ConvertFrom-Json : Invalid JSON primitive: .
At line:11 char:21
+ $json = $response | ConvertFrom-Json
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [ConvertFrom-Json], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand
I've tried to debug it but have not found nothing specific that would help.
HELP is what I need dear community 🙂
Hi @Anonymous ,
Based on the description, try to modify the json body and enter the following body formula.
# Replace with your actual report ID
$reportId = "64d5d4d4-i96a-..."
$url = "https://api.powerbi.com/v1.0/myorg/reports/$reportId/GenerateToken"
$body = @{
"accessLevel" = "View"
} | ConvertTo-Json
$response = Invoke-PowerBIRestMethod -Url $url -Body $body -Method Post
# Parse the response
$json = $response | ConvertFrom-Json
$json.token
You can view the following documents to learn more information.
Generate an embed token in Power BI embedded analytics - Power BI | Microsoft Learn
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
| User | Count |
|---|---|
| 45 | |
| 44 | |
| 40 | |
| 15 | |
| 15 |