<?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 Cursor not Working in Web Tool in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/cursor-not-working-in-web-tool/m-p/1211751#M65535</link>
    <description>&lt;P&gt;I am trying to create a web tool from a .pyt that will add a new feature to a feature class based on xy values. I have the working fine with local data in Arc Pro, but it does not work when it is shared as a web tool. I believe that I narrowed it down to the&amp;nbsp;arcpy.da.InsertCursor not accepting the REST page of my hosted feature layer as a parameter. I want this tool to eventually end up in a geoprocessing widget in Web App Builder app.&lt;/P&gt;&lt;P&gt;Is there a way around the cursor not working?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&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;&lt;LI-CODE lang="python"&gt;param0 = parameters[0].valueAsText #Feature class to gain entry
param1 = parameters[1].valueAsText #x
param2 = parameters[2].valueAsText #y
        
#Message showing params values
arcpy.AddMessage('param0 = ' + param0 + '\n' + 'param1 = ' + param1 + '\n' + 'param2 = ' + param2)

#Define the coodrdinates from parameters
coord_string = f'{param2} {param1}'

#creating a point
point_geometry = arcpy.FromCoordString(coord_string, 'DD')

#Add a messege with details about point
spatref = point_geometry.spatialReference.factoryCode
coord = point_geometry[0]
arcpy.AddMessage(f'spatial reference = {spatref} \n coodinates = {coord}')

# Create an insert cursor for a table specifying the fields that will have values provided
fields = ['SHAPE@','SHAPE@']
cursor = arcpy.da.InsertCursor(param0, fields)
        
# Create new rows  
cursor.insertRow([point_geometry, point_geometry])
        
# Delete cursor object
del cursor&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;&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;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2022-09-12_11-39-26.jpg" style="width: 428px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/50956iE2DE45A4E9D2422A/image-size/large?v=v2&amp;amp;px=999" role="button" title="2022-09-12_11-39-26.jpg" alt="2022-09-12_11-39-26.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Sep 2022 22:52:04 GMT</pubDate>
    <dc:creator>LukeHenderson1</dc:creator>
    <dc:date>2022-09-12T22:52:04Z</dc:date>
    <item>
      <title>Cursor not Working in Web Tool</title>
      <link>https://community.esri.com/t5/python-questions/cursor-not-working-in-web-tool/m-p/1211751#M65535</link>
      <description>&lt;P&gt;I am trying to create a web tool from a .pyt that will add a new feature to a feature class based on xy values. I have the working fine with local data in Arc Pro, but it does not work when it is shared as a web tool. I believe that I narrowed it down to the&amp;nbsp;arcpy.da.InsertCursor not accepting the REST page of my hosted feature layer as a parameter. I want this tool to eventually end up in a geoprocessing widget in Web App Builder app.&lt;/P&gt;&lt;P&gt;Is there a way around the cursor not working?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&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;&lt;LI-CODE lang="python"&gt;param0 = parameters[0].valueAsText #Feature class to gain entry
param1 = parameters[1].valueAsText #x
param2 = parameters[2].valueAsText #y
        
#Message showing params values
arcpy.AddMessage('param0 = ' + param0 + '\n' + 'param1 = ' + param1 + '\n' + 'param2 = ' + param2)

#Define the coodrdinates from parameters
coord_string = f'{param2} {param1}'

#creating a point
point_geometry = arcpy.FromCoordString(coord_string, 'DD')

#Add a messege with details about point
spatref = point_geometry.spatialReference.factoryCode
coord = point_geometry[0]
arcpy.AddMessage(f'spatial reference = {spatref} \n coodinates = {coord}')

# Create an insert cursor for a table specifying the fields that will have values provided
fields = ['SHAPE@','SHAPE@']
cursor = arcpy.da.InsertCursor(param0, fields)
        
# Create new rows  
cursor.insertRow([point_geometry, point_geometry])
        
# Delete cursor object
del cursor&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;&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;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2022-09-12_11-39-26.jpg" style="width: 428px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/50956iE2DE45A4E9D2422A/image-size/large?v=v2&amp;amp;px=999" role="button" title="2022-09-12_11-39-26.jpg" alt="2022-09-12_11-39-26.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 22:52:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cursor-not-working-in-web-tool/m-p/1211751#M65535</guid>
      <dc:creator>LukeHenderson1</dc:creator>
      <dc:date>2022-09-12T22:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Cursor not Working in Web Tool</title>
      <link>https://community.esri.com/t5/python-questions/cursor-not-working-in-web-tool/m-p/1215071#M65661</link>
      <description>&lt;P&gt;InsertCursors do not work with REST endpoints because it is an entirely different ecosystem. The REST endpoint is essentially server side code, which takes requests through http (GET, POST, PUT, DELETE, PATCH, etc.) and returns information. To do anything with the underlying data, you need to format your request to the REST endpoint accordingly.&lt;/P&gt;&lt;P&gt;I think you may have two options here.&amp;nbsp; You can use the ArcGIS for Python API methods to insert the points on the hosted Featurclass, or if you are stuck having to use the REST endpoint, there are some things that you need to set up to allow POST edits to that featureserver. Finally, in your web tool, you'll need to replace the Insert cursor with which ever method you chose to pursue.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html" target="_blank" rel="noopener"&gt;ArcGIS for Python features&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/update-features.htm" target="_blank" rel="noopener"&gt;REST API update Features&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 13:41:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cursor-not-working-in-web-tool/m-p/1215071#M65661</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-09-22T13:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Cursor not Working in Web Tool</title>
      <link>https://community.esri.com/t5/python-questions/cursor-not-working-in-web-tool/m-p/1215523#M65671</link>
      <description>&lt;P&gt;Thank you for the help. That makes a lot of sense. I think that I was getting hung up on the ESRI web tool documentation that says any script should work.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LukeHenderson1_0-1663944916167.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52027i2D07A2AEA511A6A2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LukeHenderson1_0-1663944916167.png" alt="LukeHenderson1_0-1663944916167.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 14:55:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cursor-not-working-in-web-tool/m-p/1215523#M65671</guid>
      <dc:creator>LukeHenderson1</dc:creator>
      <dc:date>2022-09-23T14:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Cursor not Working in Web Tool</title>
      <link>https://community.esri.com/t5/python-questions/cursor-not-working-in-web-tool/m-p/1215823#M65681</link>
      <description>&lt;P&gt;That's how they get ya!&amp;nbsp; That first part of that sentence, (and more importantly, the first word (Most...) is the kicker.&amp;nbsp; They should probably rephrase that whole statement.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need any help with either of those options, there are some smart folks on here.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Sep 2022 17:43:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cursor-not-working-in-web-tool/m-p/1215823#M65681</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-09-24T17:43:49Z</dc:date>
    </item>
  </channel>
</rss>

