Forum Discussion
Unauthorized response getting reports through groups endpoint of API
- 8 years ago
Eric, in preparing to reply to you I finally discovered the problem. In my C# code I was sending the HTTP request like this:
HttpWebRequest request = CreatePowerBiApiRequest("groups/{groupId}/reports", accessToken);What I realized today is that I forgot the $ at the beginning of the string so that the string interpolation would occur. It should have been like this:
HttpWebRequest request = CreatePowerBiApiRequest($"groups/{groupId}/reports", accessToken);So the request was just statically sending the string "{groupId}" in the request instead of substituting in the actual group ID value. Totally my bad! :smileyembarrassed:
Thanks for your help!
pangelino wrote:
I'm using the Power API REST API to first retrieve groups that the logged in user has access to, and then to retrieve reports within those groups. I can successfully retrieve reports through the https://api.powerbi.com/v1.0/myorg/reports endpoint, but if I make the request through the https://api.powerbi.com/v1.0/myorg/groups/{group_id}/reports endpoint with any of the retrieved group id's, I get a 401 - Unauthorized response. I am sending the access token as an authorization header using the "Bearer {token}" format, the same as when I successfully retrieve reports independent of the group id. Can anyone suggest what the problem is here? Thanks in advance!
Is the registered app with sufficient permissions? You can check the permission in Azure portal->Active Directory->App registrations. The delegated perssions count shall be 14.
Is your account a member of the workspace group?
Eric_ZhangI'm still stuck on this. Would you recommend that I open a ticket with technical support on this?
- Eric_Zhang8 years agoMicrosoft Employee
Is the groupid correct? Can you send the accesstoken in your case to me through a private message?
- pangelino8 years agoRegular Visitor
Eric, in preparing to reply to you I finally discovered the problem. In my C# code I was sending the HTTP request like this:
HttpWebRequest request = CreatePowerBiApiRequest("groups/{groupId}/reports", accessToken);What I realized today is that I forgot the $ at the beginning of the string so that the string interpolation would occur. It should have been like this:
HttpWebRequest request = CreatePowerBiApiRequest($"groups/{groupId}/reports", accessToken);So the request was just statically sending the string "{groupId}" in the request instead of substituting in the actual group ID value. Totally my bad! :smileyembarrassed:
Thanks for your help!