cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Create Report in Embedded Power BI with GenerateTokenRequestV2

Hi,

I have a powerBI embedded into a web application. The app contains a feature to create new reports as well that will save it into a workspace with the specified dataset.

The new experience workspaces came up with the dataset sharing capability, that'll enable users to create reports across multiple workspaces but using the dataset from one workspace. I've used the GenerateTokenRequestV2 to generate the embed token and used the Microsoft client library for JS PowerBI-Client to embed the same.

Am able to successfully embed and work on creating the report with the specified dataset, but there is an error thrown up on trying to save the report.
The network tab shows a call with endpoint "https://wabi-west.../explore/explorations?name={Report Name}" returning 403 status code.

 

Any help appreciated. Thanks in advance. 

7 REPLIES 7
shietpas_cbts
Regular Visitor

I am also experiencing this issue.  I am generating embed token using pbiClient.Reports.GenerateTokenForCreateInGroup(targetWorkspaceId, tokenRequestParams);  In the client, I call powerbi.createReport(embedContainer, embedCreateConfiguration); where embedCreateConfiguration includes groupId of target workspace.  In the generated report object, I can see the groupId and datasetId represented in the createConfig attributes.  The standard SaveAs dialog will successfully save the report; however:

I updated the embedCreateConfiguration settings to include: useCustomSaveAsDialog: true

I added event handler for the saveAsTriggered event.  I then set targetWorkspaceId as part of the saveAsParameters similar to documentation here.  However, calling the saveAs function does not succeed in saving the report.  That is when I get 403 error similar to above:

https://wabi-us-north-central-b-redirect.analysis.windows.net/explore/explorations/?name=test

 

Using the error event handler I captured the error object:

  • detailedMessage: "Unable to save the report"
  • errorCode: undefined
  • level: 2
  • message: "ExplorationContainer_FailedToSaveReportDefaultDetails"

I would expect this to be effectively the same as the standard SaveAs dialog.  I can't find any information on the ExplorationContainer message.  The example SaveAs code is quite simple, so I'm wondering if this is a bug?

 

I am using:

  • Microsoft.PowerBI.API (3.28.1)
  • Microsoft.PowerBI.JavaScript (2.18.6)

 

The service principal has the required API permissions: Workspace.ReadWrite.All, Report.ReadWrite.All, Dataset.ReadWrite.All

And the fact that the standard dialog saves makes it seem like it is not a permission issue.

 

Any insight into how I can force the standard SaveAs dialog to use the target workspace or how I can get the custom dialog to work?

I was able to resolve the issue...

 

I changed my code to use the same “pbiClient.EmbedToken.GenerateToken” API call as view/edit rather than the “pbiClient.Reports.GenerateTokenForCreateInGroup” API call.  My understanding was that report creation required the more specific call for creating a report in a group.  However, it appears that it was the cause of the issue, and is still a v1 call.

 

Using the GenerateToken API instead did resolve the issue.  The custom SaveAs dialog now works and allows me to save to the target workspace.  I simply provide Guid.Empty for the reports portion of the GenerateTokenRequestV2 and include the Dataset and targetWorkspace.

V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

You need to purchase Power BI Embedded.

https://docs.microsoft.com/en-us/power-bi/developer/embedded/azure-pbie-what-is-power-bi-embedded 

 

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

Anonymous
Not applicable

Hi @V-lianl-msft ,

The account is provisioned with PRO license but the workspace is under a dedicated premium capacity and the tenant runs under a Power BI Premium subscription.

Is the Power BI Embedded license still required?

Hi @Anonymous ,

 

Not required.

Refer to this article and check your settings and limitations to see if you can solve your issue.

https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-service-principal 

If your issue occurs frequently and you need additional help, you could have a support by creating a ticket in Power BI support.

Support_Ticket.gif

 

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

 

V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

What kind of license is your account?Pro?Free?Embeded?

https://azure.microsoft.com/en-us/services/power-bi-embedded/#documentation 

 

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

Anonymous
Not applicable

Hi @V-lianl-msft ,

 

The account is provisioned with Powe BI PRO license.

 

I tried creating the report in the similar way (with shared dataset) in the power BI web app directly and it worked fine, but facing the issue when doing it via embedded mode in our web application.

 

This is the config I send to the "powerbi-client" library.

{
      type: 'report',
      tokenType: 1,
      accessToken: '__access_token__',
      embedUrl 'https://app.powerbi.com/reportEmbed',
      datasetId: '__shared_datasetID__',
      groupId: '__target_workspaceID__',
}

Helpful resources

Announcements
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Show episode 9

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 25

Ted's Dev Camp - August 25, 2022

Watch Session 25 of Ted's Dev Camp.

Top Solution Authors
Top Kudoed Authors