<?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 Re: Portal data with stand alone script? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1210760#M65511</link>
    <description>&lt;P&gt;Doing it in Pro sets the workspace so you can use just the names and it will find it like it did.&amp;nbsp; Since workspace is not set in the standalone script, you need to include the full path to the dataset. The second thing is there is a difference between arcpy and ArcGIS for Python and there is some overlap, but generally its:&lt;/P&gt;&lt;P&gt;local data = arcpy&lt;/P&gt;&lt;P&gt;portal/agol = arcgis for python&lt;/P&gt;&lt;P&gt;I suspect it is the inner workings of Pro's C++ code to resolve commands based on arguments past in from Pro (Overloading). In the stand alone arcpy script, it is a direct call to the C++ method that is more specific to the inputs it will accept, such as a local Feature Layer, and not a hosted Feature Layer.&lt;/P&gt;&lt;P&gt;I think deleting/updating the hosted feature layer with ArcGIS for Python would be the appropriate mechanism to interact with that type of data.&amp;nbsp; Try using &lt;A href="https://developers.arcgis.com/python/guide/editing-features/" target="_blank" rel="noopener"&gt;edit_features&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Thu, 08 Sep 2022 14:13:55 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2022-09-08T14:13:55Z</dc:date>
    <item>
      <title>Portal data with stand alone script?</title>
      <link>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208817#M65456</link>
      <description>&lt;P&gt;I'm trying to automate some workflow that happens weekly.&amp;nbsp; Got everything working except for removing the old and uploading the new data at the end.&amp;nbsp; When done manually in ArcGIS Pro this is done using the Delete Features tool, then the Append tool.&amp;nbsp; I put a model together to chain the two, I can run the model in Pro using the Python window and it works fine, but when I transfer the code to my script and run it stand alone it fails with a "ERROR 000732: Target Dataset: Dataset LayerName does not exist or is not supported"&amp;nbsp; - the layer is hosted on our enterprise portal, so I thought maybe I needed to&amp;nbsp; use&amp;nbsp;&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;from arcgis.gis import GIS
gis = GIS("http://my.portal.address/", "username", "password")
LayerName = gis.content.get('f6f63262826e40adbc34e8d01ff9b3aa')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this also fails with a&amp;nbsp;&lt;/P&gt;&lt;P&gt;"""&lt;/P&gt;&lt;P&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 4241, in DeleteFeatures&lt;BR /&gt;raise e&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 4238, in DeleteFeatures&lt;BR /&gt;retval = convertArcObjectToPythonObject(gp.DeleteFeatures_management(*gp_fixargs((in_features,), True)))&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in &amp;lt;lambda&amp;gt;&lt;BR /&gt;return lambda *args: val(*gp_fixargs(args, True))&lt;BR /&gt;RuntimeError: Object: Error in executing tool&lt;/P&gt;&lt;P&gt;"""&lt;/P&gt;&lt;P&gt;I've tried entering everything into a Jupyter Notebook and viewing the file after assigning the portal path and it is displaying as expected, but I can't go any farther without errors.&amp;nbsp; If I use a local path and file everything works fine, and I've tried a few different layers from our portal and they all produce the same error.&amp;nbsp; Hoping for some help, thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 15:42:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208817#M65456</guid>
      <dc:creator>AustinBachurski</dc:creator>
      <dc:date>2022-09-08T15:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: Portal data with stand alone script?</title>
      <link>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208826#M65457</link>
      <description>&lt;P&gt;"gis.content.get()" returns an Item. Sounds like you need a layer inside that Item. There is a layer.fromitem method that should work or Item has a "layers" property.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;myItem = gis.content.get('f6f63262826e40adbc34e8d01ff9b3aa')
myLayer = myItem.layers[0]
myLayer&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 01 Sep 2022 18:39:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208826#M65457</guid>
      <dc:creator>dgiersz_cuyahoga</dc:creator>
      <dc:date>2022-09-01T18:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: Portal data with stand alone script?</title>
      <link>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208833#M65458</link>
      <description>&lt;P&gt;Putting that into the notebook to inspect, that produces the url for the map service, but I still get the same error when trying to run the delete operation.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 18:53:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208833#M65458</guid>
      <dc:creator>AustinBachurski</dc:creator>
      <dc:date>2022-09-01T18:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Portal data with stand alone script?</title>
      <link>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208836#M65459</link>
      <description>&lt;P&gt;How is the layer referenced in the python script exported from Modelbuilder? Is it url to the layer?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 19:03:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208836#M65459</guid>
      <dc:creator>dgiersz_cuyahoga</dc:creator>
      <dc:date>2022-09-01T19:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Portal data with stand alone script?</title>
      <link>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208840#M65460</link>
      <description>&lt;P&gt;In the exported script it just has the name of the layer as displayed in the Contents pane.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 19:06:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208840#M65460</guid>
      <dc:creator>AustinBachurski</dc:creator>
      <dc:date>2022-09-01T19:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: Portal data with stand alone script?</title>
      <link>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208844#M65461</link>
      <description>&lt;P&gt;When I export a Model to python window, it shows the Model Environment settings and one is the URL to the layer, like layername = url to endpoint&lt;/P&gt;&lt;P&gt;Then when it calls the delete features, it uses that for the in_features parameter:&lt;/P&gt;&lt;P&gt;DeleteFeatures(in_features=layername)&lt;/P&gt;&lt;P&gt;Unfortunately, I don't have any data handy to test this with. So I can't run it myself. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 19:14:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208844#M65461</guid>
      <dc:creator>dgiersz_cuyahoga</dc:creator>
      <dc:date>2022-09-01T19:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Portal data with stand alone script?</title>
      <link>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208849#M65462</link>
      <description>&lt;P&gt;So this is a direct copy/paste from the python window when I click "Export&amp;gt;Send to Python Window" - which works in Pro, but putting that into a standalone script results in the "ERROR 000732: Input Features: Dataset CrimeWebMap does not exist or is not supported&amp;nbsp; &amp;nbsp;Failed to execute (DeleteFeatures)." error.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# -*- coding: utf-8 -*-
"""
Generated by ArcGIS ModelBuilder on : 2022-09-01 13:17:09
"""
import arcpy

def UpdateCrimeMap():  # Update Crime Map

    # To allow overwriting outputs change overwriteOutput option to True.
    arcpy.env.overwriteOutput = False

    Backup = "Backup"
    CrimeWebMap = "CrimeWebMap"

    # Process: Remove Old Data (Delete Features) (management)
    Old_Data_Cleared = arcpy.management.DeleteFeatures(in_features=CrimeWebMap)[0]

    # Process: Append New Data (Append) (management)
    Web_Map_Updated = arcpy.management.Append(inputs=[Backup], target=Old_Data_Cleared, schema_type="TEST", field_mapping="", subtype="", expression="")[0]

if __name__ == '__main__':
    # Global Environment settings
    with arcpy.EnvManager(scratchWorkspace=r"J:\Austin\Crime Map Backup\CurrentWebmapData\ProMapping\ProMapping.gdb", workspace=r"J:\Austin\Crime Map Backup\CurrentWebmapData\ProMapping\ProMapping.gdb"):
        UpdateCrimeMap()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 15:34:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208849#M65462</guid>
      <dc:creator>AustinBachurski</dc:creator>
      <dc:date>2022-09-08T15:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Portal data with stand alone script?</title>
      <link>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208862#M65464</link>
      <description>&lt;P&gt;Change the CrimeWebMap value to the URL of the endpoint.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 19:36:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208862#M65464</guid>
      <dc:creator>dgiersz_cuyahoga</dc:creator>
      <dc:date>2022-09-01T19:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: Portal data with stand alone script?</title>
      <link>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208867#M65465</link>
      <description>&lt;P&gt;Produces the same 732 error "does not exist or is not supported".&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 19:47:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1208867#M65465</guid>
      <dc:creator>AustinBachurski</dc:creator>
      <dc:date>2022-09-01T19:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Portal data with stand alone script?</title>
      <link>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1210760#M65511</link>
      <description>&lt;P&gt;Doing it in Pro sets the workspace so you can use just the names and it will find it like it did.&amp;nbsp; Since workspace is not set in the standalone script, you need to include the full path to the dataset. The second thing is there is a difference between arcpy and ArcGIS for Python and there is some overlap, but generally its:&lt;/P&gt;&lt;P&gt;local data = arcpy&lt;/P&gt;&lt;P&gt;portal/agol = arcgis for python&lt;/P&gt;&lt;P&gt;I suspect it is the inner workings of Pro's C++ code to resolve commands based on arguments past in from Pro (Overloading). In the stand alone arcpy script, it is a direct call to the C++ method that is more specific to the inputs it will accept, such as a local Feature Layer, and not a hosted Feature Layer.&lt;/P&gt;&lt;P&gt;I think deleting/updating the hosted feature layer with ArcGIS for Python would be the appropriate mechanism to interact with that type of data.&amp;nbsp; Try using &lt;A href="https://developers.arcgis.com/python/guide/editing-features/" target="_blank" rel="noopener"&gt;edit_features&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 14:13:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1210760#M65511</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-09-08T14:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Portal data with stand alone script?</title>
      <link>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1210803#M65514</link>
      <description>&lt;P&gt;I was finally able to get it figured out late last night with some help from Esri support and a lot of googling, the syntax to login to the portal with a stand alone script is different than the syntax used in a notebook, which is what I was using previously (I think)...&amp;nbsp; &amp;nbsp;So this section was totally unnecessary.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
gis = GIS("http://my.portal.address/", "username", "password")
LayerName = gis.content.get('f6f63262826e40adbc34e8d01ff9b3aa')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After removing that I just had to add this to the code prior to trying to interact with the portal item.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.SignInToPortal(arcpy.GetActivePortalURL(), 'USERNAME', 'PASSWORD')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I had to change the target for the file to the web address for the map server.&amp;nbsp; I did have to add a "/0" to the end of the web address, if I'm honest I'm not sure why that is - guessing it selects the specific layer in the feature?&amp;nbsp; Not sure, but it wouldn't work without it...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;CrimeWebData = "https://portal.address/FeatureServer/0"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After making those changes it works as expected.&amp;nbsp; Thanks for the help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2022 15:33:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/portal-data-with-stand-alone-script/m-p/1210803#M65514</guid>
      <dc:creator>AustinBachurski</dc:creator>
      <dc:date>2022-09-08T15:33:50Z</dc:date>
    </item>
  </channel>
</rss>

