I need to access a secured feature layer that belongs to my group. I have implemented the OAuth login and am able to access my own content. However, I cannot seem to be able to find a way to reach into my groups content list. Anyone has any suggestions?
Thanks!
Solved! Go to Solution.
It is a two step process because for some reason when you query for the contents of a group you need the group id not the group name.
This will get you the PortalGroup object
private async Task<PortalGroup> GroupFromTitle(string groupTitle)
{
PortalQueryParameters parameters = PortalQueryParameters.CreateForGroups("", groupTitle);
PortalQueryResultSet<PortalGroup> groupResultSet = await _portal.FindGroupsAsync(parameters);
PortalGroup offlineGroup = groupResultSet.Results.FirstOrDefault();
return offlineGroup;
}
You can pass in the group from above and this will return the items in that group.
private async Task LoadItemsFromGroup(PortalGroup portalGroup, PortalItemType itemType)
{
PortalQueryParameters groupParameters = PortalQueryParameters.CreateForItemsOfTypeInGroup(itemType, portalGroup.GroupId);
PortalQueryResultSet<PortalItem> queryResultSet = await portalGroup.Portal.FindItemsAsync(groupParameters);
foreach (var portalItem in queryResultSet.Results)
{
PortalItems.Add(new PortalListItem(portalItem));
}
}
Hi Yifan,
Have you tried to use PortalItem.GetGroupsAsync() to get the list of the groups you have access. I think once you get the access of theat group, you may find the list of the available contents in that group.
PortalItem Methods --> "Gets the groups the item is a part of. Only shows the groups which the calling user can access."
Hope that helps.
Nagma
The PortalGroup class, which can be accessed through getGroupsAsync, does not provide a way to see the content in the group. But thanks still Nagma!
Is the issue not knowing how to query a group or not seeing the group event though you are a member? The former would be answered using the method described above, and there are various ways to query groups. I have come across the latter issue which required a Portal reboot. I don't understand why this is, just know it solved the problem. I had groups that I was a member, I could log onto Portal through the browser and see the group and content, however, when I queried from Runtime the groups were not found. After pulling out my hair for a few hours decided to reboot Portal and that fixed the issue.
Could you elaborate how to query group content? GetGroupsAsync does not seem to provide a way to query the content in a group.
It is a two step process because for some reason when you query for the contents of a group you need the group id not the group name.
This will get you the PortalGroup object
private async Task<PortalGroup> GroupFromTitle(string groupTitle)
{
PortalQueryParameters parameters = PortalQueryParameters.CreateForGroups("", groupTitle);
PortalQueryResultSet<PortalGroup> groupResultSet = await _portal.FindGroupsAsync(parameters);
PortalGroup offlineGroup = groupResultSet.Results.FirstOrDefault();
return offlineGroup;
}
You can pass in the group from above and this will return the items in that group.
private async Task LoadItemsFromGroup(PortalGroup portalGroup, PortalItemType itemType)
{
PortalQueryParameters groupParameters = PortalQueryParameters.CreateForItemsOfTypeInGroup(itemType, portalGroup.GroupId);
PortalQueryResultSet<PortalItem> queryResultSet = await portalGroup.Portal.FindItemsAsync(groupParameters);
foreach (var portalItem in queryResultSet.Results)
{
PortalItems.Add(new PortalListItem(portalItem));
}
}
This is exactly what I need, thank you!