Gets the collection of portal items.
Portal: Get the user content for the active user from the active portal
var portal = ArcGISPortalManager.Current.GetActivePortal();
var owner = portal.GetSignOnUsername();
var userContent = await portal.GetUserContentAsync(owner);
//Get content for a specific folder (identified by its folder id)
//var userContent = await portal.GetUserContentAsync(owner, folderId);
//Get all the folders
foreach (var pf in userContent.PortalFolders)
{
//Do something with the folders
}
//Get all the content items
foreach (var pi in userContent.PortalItems)
{
//Do something with the portal items
}
Portal: Download any package items in the user content
//user content previously from...
//var userContent = await portal.GetUserContentAsync(owner);
var packages = new List<PortalItemType>
{
PortalItemType.BasemapPackage,
PortalItemType.GeoprocessingPackage,
PortalItemType.LayerPackage,
PortalItemType.LocatorPackage,
PortalItemType.MapPackage,
PortalItemType.ProjectPackage,
PortalItemType.ScenePackage,
PortalItemType.RulePackage,
PortalItemType.VectorTilePackage
};
var folder = @"E:\Temp\PortalAPITest\";
foreach (var di in userContent.PortalItems.Where(pi => packages.Contains(pi.PortalItemType)))
{
var path = System.IO.Path.Combine(folder, di.Name);
await di.GetItemDataAsync(path);
}
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.