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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
UmeshGoti
Helper I
Helper I

Need to create powerbi report with visualization through API mechanism

Hello Community,

I have requirement to generate powerbi report including visual part

 

currently i am able to generate semantic layer using API approach
https://learn.microsoft.com/en-us/rest/api/fabric/semanticmodel/items/create-semantic-model?tabs=HTT...

 

but we have requirement to create visual representation also for the generated semantic layer

 

can someone help me on this how we can generate visual for semantic layer through API

 

Thanks !!

2 REPLIES 2
Anonymous
Not applicable

Hi,  @UmeshGoti 

You've built a semantic layer using the API. Then use the Power BI REST API to build the visualization. You'll need to generate an embed token to validate your API request. This token allows you to embed Power BI reports and dashboards. Use the Power BI REST API to create a report. You can specify a dataset (semantic model) that you created earlier. Once the report is created, you can add visualizations to it. This involves specifying the type of visualization (e.g., bar chart, pie chart) and the data field you want to use.

To generate an embed token:

POST https://api.powerbi.com/v1.0/myorg/reports/{reportId}/GenerateToken

 

To create a report:

POST https://api.powerbi.com/v1.0/myorg/reports
{
  "datasetId": "your-dataset-id",
  "name": "Your Report Name"
}

 

To add a visualization:

POST https://api.powerbi.com/v1.0/myorg/reports/{reportId}/pages/{pageName}/visuals
{
  "visualType": "barChart",
  "dataFields": ["field1", "field2"]
}

You can learn from the following link:

Power BI REST APIs for embedded analytics and automation - Power BI REST API | Microsoft Learn

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks @Anonymous  for your quick and useful reply

as i am able to generate embed token using below api
Type : POST
URL : https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports/{reportId}/GenerateToken
Request Body : 

{
    "accessLevel": "View"
}

but when i try to create report using below API
Type : POST
URL : https://api.powerbi.com/v1.0/myorg/groups/{groupId}/reports
Request Body : 
{
  "datasetId": "123-xyz",
  "name": "Your Report Name"
}

in response it says 
{
    "error": {
        "code": "",
        "message": "No HTTP resource was found that matches the request URI 'https://wabi-south-east-asia-redirect.analysis.windows.net/v1.0/myorg/groups/{groupId}/reports'."
    }
}

so when i asked to co-pilot it says like below


The error message you're encountering suggests that the endpoint you're trying to use is not supported for creating reports. As of now, the Power BI REST API does not support creating reports directly from scratch. Instead, you can create a report by importing a Power BI Desktop (.pbix) file or by cloning an existing report.

and if i use co-pilot suggested approach i can not create report dynamic, as i need to stick with the pbix template which i create in powerbi desktop

 

Also i am not getting idea where embed token we can use

can you please help me on this 

Thanks !!!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.