ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Core.Portal Namespace / PortalItem Class / PortalItemType Property
Example

In This Topic
    PortalItemType Property
    In This Topic
    Gets the GIS content type of this item.
    Syntax
    public PortalItemType PortalItemType {get;}
    Public ReadOnly Property PortalItemType As PortalItemType
    Remarks
    Example types include : "Web Map" and "Web Mapping Application"
    Example
    Retrieve a project item from a portal and open it
    {
      var projectPortal = ArcGISPortalManager.Current.GetPortal(new Uri(@"https://<serverName>.<domain>.com/portal/", UriKind.Absolute));
      string owner = string.Empty;
      //Get the signed on user name
      owner = await QueuedTask.Run(() => projectPortal.GetSignOnUsername());
      //Get the user content from the portal
      PortalUserContent userContent = await projectPortal.GetUserContentAsync(owner);
      //Get the first portal project item
      var firstPortalProject = userContent.PortalItems.FirstOrDefault(pi => pi.PortalItemType == PortalItemType.ProProject);
      var portalProjectUri = firstPortalProject.ItemUri.ToString();
      //Check if project can be opened
      string docVer = string.Empty;
      if (Project.CanOpen(portalProjectUri, out docVer))
      {
        Project.OpenAsync(portalProjectUri);
      }
      //Note: If Project.CanOpen returns false, the project cannot be opened. One reason could be
      // the active portal is not the same as the portal of the project. Refer to the snippet: [Workflow to open an ArcGIS Pro project](ProSnippets-sharing#workflow-to-open-an-arcgis-pro-project)
    }
    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