ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Core Namespace / ArcGISPortalExtensions Class / GetPortalInfoAsync Method
Example

In This Topic
    GetPortalInfoAsync Method
    In This Topic
    Executes a self query on the specified portal to return its ArcGIS.Desktop.Core.Portal.PortalInfo.
    Syntax
    public static Task<PortalInfo> GetPortalInfoAsync( 
       ArcGISPortal portal
    )
    Public Shared Function GetPortalInfoAsync( _
       ByVal portal As ArcGISPortal _
    ) As Task(Of PortalInfo)

    Parameters

    portal

    Return Value

    Exceptions
    ExceptionDescription
    Thrown when an invalid portal is provided as the active portal.
    You do not have permissions to access this resource or perform this operation.
    Request failed: status code {status code}.
    Remarks
    This method will return (via portal self) the view of the portal as seen by the current user, whether anonymous or logged in. It uses the current culture, as specified, for ArcGIS Pro. Portal info includes information such as the name, logo, featured items, group queries, organization info, etc. for this portal. If the user is not logged in, this call will return the default view of the portal. If the user is logged in, the view of the returned portal will be specific to the organization to which the user belongs. The default view of the portal is dependent on the culture of the user, which is obtained from the user's profile.
    Example
    Portal: Get the "online" portal view for the current user
    //If no-one is signed in, this will be the default view for
    //the anonymous user.
    var online = ArcGISPortalManager.Current.GetPortal(new Uri("http://www.arcgis.com"));
    var portalInfo = await online.GetPortalInfoAsync();
    
    Portal: Get the organization id for the current user
    var portal = ArcGISPortalManager.Current.GetPortal(new Uri(portalUri));
    var portalInfo = await portal.GetPortalInfoAsync();
    var orgid = portalInfo.OrganizationId;
    
    Portal: Execute a portal search
    var portal = ArcGISPortalManager.Current.GetPortal(portalUri);
    var owner = portal.GetSignOnUsername();
    var portalInfo = await portal.GetPortalInfoAsync();
    
    //1. Get all web maps
    var query1 = PortalQueryParameters.CreateForItemsOfType(PortalItemType.WebMap);
    
    //2. Get all web maps and map services - include user, organization
    // and "usa" in the title
    var query2 = PortalQueryParameters.CreateForItemsOfTypes(new List<PortalItemType>() {
      PortalItemType.WebMap, PortalItemType.MapService}, owner, "", "title:usa");
    query2.OrganizationId = portalInfo.OrganizationId;
    
    //retrieve in batches of up to a 100 each time
    query2.Limit = 100;
    
    //Loop until done
    var portalItems = new List<PortalItem>();
    while (query2 != null)
    {
      //run the search
      PortalQueryResultSet<PortalItem> results = await portal.SearchForContentAsync(query2);
      portalItems.AddRange(results.Results);
      query2 = results.NextQueryParameters;
    }
    
    //process results
    foreach (var pi in portalItems)
    {
      //Do something with the portal items
    }
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also