<?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 Access published service when logged out of Portal in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-published-service-when-logged-out-of-portal/m-p/1474569#M10034</link>
    <description>&lt;P&gt;I'm trying to create a script that will run as scheduled task on a server that has Pro installed but Pro may not be logged into my Portal at all times.&lt;/P&gt;&lt;P&gt;I have it working correctly when I'm logged into my Portal via Pro by doing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Electric_feat = "https://poralurl/layername/FeatureServer/100"
#Login into Portal
pgis = GIS(portal_url, portal_user, portal_password, verify_cert=False)
print ("Connecting to Portal")

#Select Low Voltage and Medium Voltage Meters and Meter Number is Not Null
selection = arcpy.management.SelectLayerByAttribute(Electric_feat, 'NEW_SELECTION','meternum IS NOT NULL', 'NON_INVERT')
print ("Finish Get Electric Selection")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However,&amp;nbsp; when I'm logged out of my portal I get the error that it can't access my feature service (Electric_feat)&lt;/P&gt;&lt;P&gt;So I modified the code to the below and get Object: Error in executing Tool on the select tool.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;pgis = GIS(portal_url, portal_user, portal_password, verify_cert=False)
print ("Connecting to Portal")
eflc = pgis.content.search(Electric_feat)
print (Electric_feat)

#Select Low Voltage and Medium Voltage Meters and Meter Number is Not Null
selection = arcpy.management.SelectLayerByAttribute(eflc, 'NEW_SELECTION','meternum IS NOT NULL', 'NON_INVERT')
print ("Finish Get Electric Selection")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I also tried&amp;nbsp;eflc = pgis.content.get(Electric_feat) but I get&amp;nbsp;A general expection was raised: No connection adapters were found for 'content/items/url of Electric_feat on the get script line.&lt;/P&gt;</description>
    <pubDate>Fri, 17 May 2024 14:39:54 GMT</pubDate>
    <dc:creator>LindseyStone</dc:creator>
    <dc:date>2024-05-17T14:39:54Z</dc:date>
    <item>
      <title>Access published service when logged out of Portal</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-published-service-when-logged-out-of-portal/m-p/1474569#M10034</link>
      <description>&lt;P&gt;I'm trying to create a script that will run as scheduled task on a server that has Pro installed but Pro may not be logged into my Portal at all times.&lt;/P&gt;&lt;P&gt;I have it working correctly when I'm logged into my Portal via Pro by doing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Electric_feat = "https://poralurl/layername/FeatureServer/100"
#Login into Portal
pgis = GIS(portal_url, portal_user, portal_password, verify_cert=False)
print ("Connecting to Portal")

#Select Low Voltage and Medium Voltage Meters and Meter Number is Not Null
selection = arcpy.management.SelectLayerByAttribute(Electric_feat, 'NEW_SELECTION','meternum IS NOT NULL', 'NON_INVERT')
print ("Finish Get Electric Selection")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However,&amp;nbsp; when I'm logged out of my portal I get the error that it can't access my feature service (Electric_feat)&lt;/P&gt;&lt;P&gt;So I modified the code to the below and get Object: Error in executing Tool on the select tool.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;pgis = GIS(portal_url, portal_user, portal_password, verify_cert=False)
print ("Connecting to Portal")
eflc = pgis.content.search(Electric_feat)
print (Electric_feat)

#Select Low Voltage and Medium Voltage Meters and Meter Number is Not Null
selection = arcpy.management.SelectLayerByAttribute(eflc, 'NEW_SELECTION','meternum IS NOT NULL', 'NON_INVERT')
print ("Finish Get Electric Selection")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I also tried&amp;nbsp;eflc = pgis.content.get(Electric_feat) but I get&amp;nbsp;A general expection was raised: No connection adapters were found for 'content/items/url of Electric_feat on the get script line.&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 14:39:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-published-service-when-logged-out-of-portal/m-p/1474569#M10034</guid>
      <dc:creator>LindseyStone</dc:creator>
      <dc:date>2024-05-17T14:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: Access published service when logged out of Portal</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-published-service-when-logged-out-of-portal/m-p/1474580#M10036</link>
      <description>&lt;P&gt;I have gotten around that issue by creating a profile using the ArcGIS API for Python. I create the profile outside of my script and then reference the profile in my script. Just remember that you have to create the profile under the account that will be running the script otherwise your script will not be able to find the profile.&lt;/P&gt;&lt;P&gt;For example, if you are using Windows and Task Scheduler, the profile has to be created using the account that is executing the task in Task Scheduler.&lt;/P&gt;&lt;P&gt;Here is a link describing how to create and use a profile: &lt;A href="https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/#storing-your-credentials-locally" target="_blank"&gt;https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/#storing-your-credentials-locally&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 14:54:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-published-service-when-logged-out-of-portal/m-p/1474580#M10036</guid>
      <dc:creator>Joshua-Young</dc:creator>
      <dc:date>2024-05-17T14:54:20Z</dc:date>
    </item>
  </channel>
</rss>

