ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Core.Portal Namespace / PortalItem Class
Members Example

In This Topic
    PortalItem Class
    In This Topic
    Represents an item (a unit of content) in the portal. An item may have associated binary or textual data which is available via the GetDataAsync() method.
    Object Model
    PortalItem ClassOnlineItem ClassTimeInstant Class
    Syntax
    Example
    Create A PortalItem
    // Creates an Item from an existing portal item base on its ID
    string portalItemID = "9801f878ff4a22738dff3f039c43e395";
    Item portalItem = ItemFactory.Instance.Create(portalItemID, ItemFactory.ItemType.PortalItem);
    
    Create A PortalFolder
    // Creates an Item from an existing portal folder base on its ID
    string portalFolderID = "39c43e39f878f4a2279838dfff3f0015";
    Item portalFolder = ItemFactory.Instance.Create(portalFolderID, ItemFactory.ItemType.PortalFolderItem);
    
    Get Folder Item Content from Project PortalItem
    var folderConnectionContent = projectfolderConnection.GetItems();
    var folder = folderConnectionContent.FirstOrDefault(folderItem => folderItem.Name.Equals("Tourist Sites"));
    var folderContents = folder.GetItems();
    
    Get Basemaps
    //Basemaps stored locally in the project. This is usually an empty collection
    string localBasemapTypeID = "cim_map_basemap";
    var localBasemaps = await QueuedTask.Run(() =>
    {
      var mapContainer = Project.Current.GetProjectItemContainer("Map");
      return mapContainer.GetItems().Where(i => i.TypeID == localBasemapTypeID).ToList();
    });
    
    //portal basemaps. If there is no current active portal, the usual default
    //is arcgis online
    var portal = ArcGISPortalManager.Current.GetActivePortal();
    var portalBaseMaps = await portal.GetBasemapsAsync();
    
    //use one of them...local or portal...
    //var map = MapView.Active.Map;
    //QueuedTask.Run(() => map?.SetBasemapLayers(portalBaseMaps[0]));
    
    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
    }
    
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Framework.Contracts.PropertyChangedBase
          ArcGIS.Desktop.Core.Item
             ArcGIS.Desktop.Core.Portal.OnlineItem
                ArcGIS.Desktop.Core.Portal.PortalItem

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also