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
SWAT007
New Member

GenerateTokenInGroupAsync returns BadRequest if used in GenerateTokenRequest with customData

I have the challenge, want to host a PowerBI report embedded where the Row filter is to be implemented via the CustomData feature.

 

When I use the CustomData property, I have the problem that when calling the GenerateTokenInGroupAsync function, it always throws a BadRequest error message.

 

When I call the GenerateTokenInGroupAsync function without a CustomData property I get back a valid result, only the report is not filtered.

 

Code

GenerateTokenRequest generateTokenRequestParameters = new GenerateTokenRequest(
                        accessLevel: "View",
                        identity: new EffectiveIdentity(
                            username: PowerBiAuthConstants.Username,
                            datasets: new List<string> { reportConfig.DatasetId },
                            roles: new List<string> { "Username" },
                            customData: fgnr));


var tokenResponse = await client.Reports.GenerateTokenInGroupAsync(
                        groupId: reportConfig.GroupId,
                        reportKey: report.Id,
                        requestParameters: generateTokenRequestParameters);

Exception

Massage: Operation returned an invalid status code 'BadRequest'

StackTrace:   at Microsoft.PowerBI.Api.V2.Reports.<GenerateTokenInGroupWithHttpMessagesAsync>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerBI.Api.V2.ReportsExtensions.<GenerateTokenInGroupAsync>d__55.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at KIND.PowerBI.WebApi.DataAccess.PowerBiAdapter.<CreateEmbedConfig>d__0.MoveNext() in D:\TFS\PH1\Dev\services\KIND.PowerBI.WebApi\KIND.PowerBI.WebApi\DataAccess\PowerBiAdapter.cs:line 100

 

0 REPLIES 0

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.