ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Core.Portal Namespace / PortalUserContent Class / PortalItems Property
Example

In This Topic
    PortalItems Property
    In This Topic
    Gets the collection of portal items.
    Syntax
    Public ReadOnly Property PortalItems As IReadOnlyList(Of PortalItem)
    public IReadOnlyList<PortalItem> PortalItems {get;}
    Example
    Portal: Get the user content for the active user from the active portal
    {
      var activePortal = ArcGISPortalManager.Current.GetActivePortal();
      var owner = activePortal.GetSignOnUsername();
      var activeUserContent = await activePortal.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
    {
      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\";
      //Get the UserContent - refer to the initialization section above for more details
      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);
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also