<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Get Layers from WebMap (PortalItem) in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-layers-from-webmap-portalitem/m-p/1222657#M8900</link>
    <description>&lt;P&gt;Is there a way to search the current portal for all WebMaps that contain a certain feaureservice layer?&lt;/P&gt;&lt;P&gt;I can use the myPortal.SearchForContentAsync(query) to get my webmap portal items. But don't see how to get a list of layers for the webmap.&amp;nbsp; &amp;nbsp;The GetItems() method returns nothing.&lt;/P&gt;&lt;P&gt;Looks like the ArcGIS API can do it, but I need to use the SDK.&amp;nbsp; Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;tim&lt;/P&gt;</description>
    <pubDate>Mon, 17 Oct 2022 22:33:01 GMT</pubDate>
    <dc:creator>TimothySmith6</dc:creator>
    <dc:date>2022-10-17T22:33:01Z</dc:date>
    <item>
      <title>Get Layers from WebMap (PortalItem)</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-layers-from-webmap-portalitem/m-p/1222657#M8900</link>
      <description>&lt;P&gt;Is there a way to search the current portal for all WebMaps that contain a certain feaureservice layer?&lt;/P&gt;&lt;P&gt;I can use the myPortal.SearchForContentAsync(query) to get my webmap portal items. But don't see how to get a list of layers for the webmap.&amp;nbsp; &amp;nbsp;The GetItems() method returns nothing.&lt;/P&gt;&lt;P&gt;Looks like the ArcGIS API can do it, but I need to use the SDK.&amp;nbsp; Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;tim&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 22:33:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-layers-from-webmap-portalitem/m-p/1222657#M8900</guid>
      <dc:creator>TimothySmith6</dc:creator>
      <dc:date>2022-10-17T22:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Get Layers from WebMap (PortalItem)</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-layers-from-webmap-portalitem/m-p/1222683#M8901</link>
      <description>&lt;P&gt;There is a lower level API called EsriHttpClient. You can use it to issue HTTP formatted GET requests (as well as POST, etc.) against the portal. In this way u can use the ArcGIS API as u mention, just parse the returned JSON using Newtonsoft.JSON as needed.&lt;/P&gt;&lt;P&gt;Take a look at all the examples here:&amp;nbsp;&lt;A href="https://prodev.arcgis.com/en/pro-app/latest/sdk/api-reference/topic9050.html" target="_blank"&gt;https://prodev.arcgis.com/en/pro-app/latest/sdk/api-reference/topic9050.html&lt;/A&gt;&amp;nbsp;which is part of the API Reference. They show various usages based off the ArcGIS REST API and will show u the pattern to use.&lt;/P&gt;&lt;P&gt;There are also a couple of samples that use EsriHttpClient as well. Here's one you can look at for additional context:&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Content/PortalInfoListAllFedServers" target="_blank"&gt;https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Content/PortalInfoListAllFedServers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 01:11:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-layers-from-webmap-portalitem/m-p/1222683#M8901</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2022-10-18T01:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Get Layers from WebMap (PortalItem)</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-layers-from-webmap-portalitem/m-p/1223614#M8931</link>
      <description>&lt;P&gt;Thanks Charles,&lt;/P&gt;&lt;P&gt;I think that put us on the right track.&lt;/P&gt;&lt;P&gt;So using the SDK's&amp;nbsp;&lt;SPAN&gt;myPortal.SearchForContentAsync(query)&lt;/SPAN&gt; gives us the WebMap PortalItems, with IDs.&amp;nbsp; We can then use those IDs and EsriHttpClient to get the webmap's JSON to find the operational layers (urls).&lt;/P&gt;&lt;P&gt;Something along these lines:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;string sID = "45427f94cfef46b3bd117eb9b9a9fe8a"; 
UriBuilder searchURL = new UriBuilder(ArcGISPortalManager.Current.GetActivePortal().PortalUri)
{
    Path = $"sharing/rest/content/items/{sID}/data",
    Query = "f=json"
};

EsriHttpResponseMessage response2 = new EsriHttpClient().Get(searchURL.Uri.ToString());
dynamic operLayers = JObject.Parse(await response2.Content.ReadAsStringAsync());

List&amp;lt;dynamic&amp;gt; operLayerList = new List&amp;lt;dynamic&amp;gt;();
operLayerList.AddRange(operLayers.operationalLayers);

for (int x = 0; x &amp;lt; operLayerList.Count; x++)
{
    string myURL = operLayerList[x].url;
    MessageBox.Show(myURL);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;tim&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 22:18:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/get-layers-from-webmap-portalitem/m-p/1223614#M8931</guid>
      <dc:creator>TimothySmith6</dc:creator>
      <dc:date>2022-10-19T22:18:40Z</dc:date>
    </item>
  </channel>
</rss>

