Forum Discussion
Trying to use filter parameter with C# PowerBI V2 API GetGroupsAsync()
I'm trying to select a PowerBI Embedded Group using the $filter parameter with GetGroupsAsync()
Currently I am using Microsoft Power BI Version 2 APIs with C#
This is the method I'm trying to use:
public static System.Threading.Tasks.Task<Microsoft.PowerBI.Api.V2.Models.ODataResponseListGroup> GetGroupsAsync (this Microsoft.PowerBI.Api.V2.IGroups operations, string filter = null, Nullable<int> top = null, Nullable<int> skip = null, System.Threading.CancellationToken cancellationToken = null);
I can retrieve all the Power BI Groups using the below line, so I am confident the rest of my code is functioning
var groups = await client.Groups.GetGroupsAsync();
But how does this $filter parameter need to be formatted to retrieve only one?
I found some Power BI API Version: v1.0 REST documentation
https://docs.microsoft.com/en-us/rest/api/power-bi/groups/getgroups
I just need to match the Group Id GUID in the $filter, I tried the line below with no success
var groups = await client.Groups.GetGroupsAsync($"id eq '{workspaceId.ToString()}'");
Has anyone been able to get this $filter parameter working with the Power BI Version 2 APIs and C#?
I would prefer not to resort to retrieving all the Groups and filtering within C# if the GetGroupsAsync() $filter parameter is available.
1 Reply
- yvcabreraNew Member
sample :
//list workspaces
var workspaces = await pbiClient.Groups.GetGroupsAsAdminAsync(top: 100, null, "type eq 'Workspace' and state eq 'Active'");