Forum Discussion
400 Bad Request Error when embedding report
- Anonymous6 years ago
Hi shaw
If you are using the 'App owns data' type of embedding + using the Service Principal to generate embedding tokens, then this Identity section of the token request should contain details of the 'user' used for Row Level Security purposes.
Are you reports/dashboards using Row Level Security?
If so... your identity section should look like this..."identities": [ { "username": "[email protected]", "roles": [ "My PBI Role Name" ], "datasets": [ "cfafbeb1-8037-4d0c-896e-a46fb27ff229" ] } ]Username can be any value - you are effectively impersonating this person - and this has no link to any account in your Azure tenant or Power BI access list.
Roles should contain any Power BI (RLS) roles that you have defined inside your data model. Note that you should not supply roles here if you are not using RLS - and dont supply roles that dont exist in your model. Again, this is not a role that belongs to your Service Principal account or any other Power BI account type (admin/member/viewer) etc..Hope this helps,
Cheers - Matt
If anyone is having an issue wih this, I found that submitting the JSON body in the 'Try it' section in the docs gave a much better error than the generic '400 Bad Request' error.
https://learn.microsoft.com/en-us/rest/api/power-bi/embed-token/generate-token#code-try-0