<?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: Update feature in feature service using rest in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/update-feature-in-feature-service-using-rest/m-p/431751#M33953</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Randy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Works great. I can easily change text attributes with English strings.&lt;/P&gt;&lt;P&gt;When I try to update Hebrew strings I get garbage in the feature class. In REST (in chrome) I can update Hebrew string without any problem.&lt;/P&gt;&lt;P&gt;I tried to encode/decode and do a few more tricks in python but nothing works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Any idea?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Jun 2017 05:46:05 GMT</pubDate>
    <dc:creator>ModyBuchbinder</dc:creator>
    <dc:date>2017-06-28T05:46:05Z</dc:date>
    <item>
      <title>Update feature in feature service using rest</title>
      <link>https://community.esri.com/t5/python-questions/update-feature-in-feature-service-using-rest/m-p/431747#M33949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to use python to update a feature in a feature service.&lt;/P&gt;&lt;P&gt;In simple chrome my url is:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://modyb-pc:6080/arcgis/rest/services/featureAccess/FeatureServer/0/applyEdits" title="http://modyb-pc:6080/arcgis/rest/services/featureAccess/FeatureServer/0/applyEdits"&gt;http://modyb-pc:6080/arcgis/rest/services/featureAccess/FeatureServer/0/applyEdits&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and my json in the update is:&lt;/P&gt;&lt;P&gt;[ {&lt;BR /&gt;"attributes" : {&lt;BR /&gt; "OBJECTID" : 1,&lt;BR /&gt; "CITYNAME" : "aaa"&lt;BR /&gt;}&lt;BR /&gt;} ]&lt;/P&gt;&lt;P&gt;(no adds).&lt;/P&gt;&lt;P&gt;This URL uses post only.&lt;/P&gt;&lt;P&gt;How do I call it from Python.&lt;/P&gt;&lt;P&gt;I have here:&amp;nbsp;&lt;A class="link-titled" href="https://esriaustraliatechblog.wordpress.com/2013/12/20/using-python-to-write-features-to-a-feature-service/" title="https://esriaustraliatechblog.wordpress.com/2013/12/20/using-python-to-write-features-to-a-feature-service/"&gt;Using Python to Write Features to a Feature Service | Esri Australia Technical Blog&lt;/A&gt;&amp;nbsp; example of Add but the update is not the same&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jun 2017 12:54:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-feature-in-feature-service-using-rest/m-p/431747#M33949</guid>
      <dc:creator>ModyBuchbinder</dc:creator>
      <dc:date>2017-06-22T12:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: Update feature in feature service using rest</title>
      <link>https://community.esri.com/t5/python-questions/update-feature-in-feature-service-using-rest/m-p/431748#M33950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are going to be working with ArcGIS Server, or Portal, data from Python; have you thought about using &lt;A class="link-titled" href="https://github.com/Esri/ArcREST" title="https://github.com/Esri/ArcREST"&gt;GitHub - Esri/ArcREST: python package for REST API (AGS, AGOL, webmap JSON, etc..)&lt;/A&gt;&amp;nbsp; or &lt;A class="link-titled" href="https://github.com/Esri/arcgis-python-api" title="https://github.com/Esri/arcgis-python-api"&gt;GitHub - Esri/arcgis-python-api: Documentation and samples for ArcGIS Python API&lt;/A&gt;&amp;nbsp; ?&amp;nbsp; Both of these packages abstract the messiness of Python -&amp;gt; HTTP -&amp;gt; REST from the user, and make it where we, as users, don't have to roll our own HTTP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jun 2017 14:16:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-feature-in-feature-service-using-rest/m-p/431748#M33950</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-06-22T14:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Update feature in feature service using rest</title>
      <link>https://community.esri.com/t5/python-questions/update-feature-in-feature-service-using-rest/m-p/431749#M33951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In addition to the ArcREST scripts, I also found the &lt;A href="https://www.arcgis.com/home/item.html?id=12dde73e0e784e47818162b4d41ee340"&gt;ArcGIS Server Administration Toolkit - 10.1+&lt;/A&gt;&amp;nbsp;helpful; although the code on GitHub is probably more up to date.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jun 2017 15:18:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-feature-in-feature-service-using-rest/m-p/431749#M33951</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2017-06-22T15:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: Update feature in feature service using rest</title>
      <link>https://community.esri.com/t5/python-questions/update-feature-in-feature-service-using-rest/m-p/431750#M33952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have also been experimenting with the REST API ApplyEdits function.&amp;nbsp; In my case, it is with AGOL, so you will need to modify the URLs in the example.&amp;nbsp; Updates are sent as a list of dictionaries.&amp;nbsp; Here's a code sample.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import urllib, urllib2, json, sys, collections

# get a token - this is for AGOL, modify for portal/server
username = 'xxx'
password = 'yyy'

referer = "http://www.arcgis.com/"
tokenurl = "https://www.arcgis.com/sharing/rest/generateToken"

query_dict = { 'username': username, 'password': password, 'referer': referer }
query_string = urllib.urlencode(query_dict)
token = json.loads(urllib.urlopen(tokenurl + "?f=json", query_string).read())
if "token" not in token:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(token['error'])
&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.exit(1)

#&amp;nbsp; items to update, based on OBJECTID
# OBJECTID, POINT_X, POINT_Y, City
to_update = [
&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 11, -16683056.055, 8668941.2456, 'Anchorage' ],
&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 12, -16188891.9816, 8873309.4627000019, 'Glennallen' ],
&amp;nbsp;&amp;nbsp;&amp;nbsp; [ 13, -16682516.0441, 8661113.2519000024, 'Anchorage' ]
&amp;nbsp;&amp;nbsp;&amp;nbsp; ]

updates = [] # this will be a list of dictionaries
for item in to_update
&amp;nbsp;&amp;nbsp;&amp;nbsp; dict = {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'geometry' : {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'x' : item[1],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'y' : item[2]},
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'attributes' : {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'OBJECTID' : item[0],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'City' : item[3]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; updates.append(dict)

# modify URL for your needs
URL = "https://services2.arcgis.com/&amp;lt;directory&amp;gt;/arcgis/rest/services/&amp;lt;layer&amp;gt;/FeatureServer/0/applyEdits"

query_dict = {
&amp;nbsp;&amp;nbsp;&amp;nbsp; "updates" : updates,
&amp;nbsp;&amp;nbsp;&amp;nbsp; "f": "json",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "token": token['token']
&amp;nbsp;&amp;nbsp;&amp;nbsp; }

jsonResponse = urllib.urlopen(URL, urllib.urlencode(query_dict))
response = json.loads(jsonResponse.read(),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; object_pairs_hook=collections.OrderedDict)

print json.dumps(response, indent=4, sort_keys=False) # formatted json of response
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers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;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you do not need to update geometry, you can delete lines 28-30 and modify the to_update list and indexing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For additions, the query_dict would contain the "adds" parameter which is a list of dictionaries similar to the "updates" parameter.&amp;nbsp;Features to be added should include the geometry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/arcgis-rest-api/#/Apply_Edits_Feature_Service_Layer/02r3000000r6000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;Additional documentation on ApplyEdits&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/tag/arcgis online rest api/tg-p" target="_blank"&gt;#arcgis online rest api&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:24:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-feature-in-feature-service-using-rest/m-p/431750#M33952</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-11T19:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Update feature in feature service using rest</title>
      <link>https://community.esri.com/t5/python-questions/update-feature-in-feature-service-using-rest/m-p/431751#M33953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Randy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Works great. I can easily change text attributes with English strings.&lt;/P&gt;&lt;P&gt;When I try to update Hebrew strings I get garbage in the feature class. In REST (in chrome) I can update Hebrew string without any problem.&lt;/P&gt;&lt;P&gt;I tried to encode/decode and do a few more tricks in python but nothing works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Any idea?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jun 2017 05:46:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-feature-in-feature-service-using-rest/m-p/431751#M33953</guid>
      <dc:creator>ModyBuchbinder</dc:creator>
      <dc:date>2017-06-28T05:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Update feature in feature service using rest</title>
      <link>https://community.esri.com/t5/python-questions/update-feature-in-feature-service-using-rest/m-p/431752#M33954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't have any experience using &lt;A href="https://community.esri.com/space/2145"&gt;Python&lt;/A&gt;‌ or the &lt;A href="https://community.esri.com/space/2132"&gt;ArcGIS REST API&lt;/A&gt;‌ with languages‌ other than English.&amp;nbsp; I suggest you start a new question and include an example of the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit:&amp;nbsp; However, this link on StackOverflow looked interesting: &lt;A href="https://stackoverflow.com/questions/29850912/decoding-and-encoding-hebrew-string-in-python"&gt;decoding and encoding Hebrew string in Python&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jun 2017 16:24:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/update-feature-in-feature-service-using-rest/m-p/431752#M33954</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2017-06-28T16:24:01Z</dc:date>
    </item>
  </channel>
</rss>

