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.
I have it working correctly when I'm logged into my Portal via Pro by doing.
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")
However, when I'm logged out of my portal I get the error that it can't access my feature service (Electric_feat)
So I modified the code to the below and get Object: Error in executing Tool on the select tool.
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")
I also tried eflc = pgis.content.get(Electric_feat) but I get A general expection was raised: No connection adapters were found for 'content/items/url of Electric_feat on the get script line.