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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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