POST
|
My current use case is very low volume but your example looks like a better alternative to some other work I've done using the multiprocessing package to spin off parallel requests.
... View more
08-11-2025
09:19 PM
|
1
|
0
|
833
|
POST
|
I never really figured this out but was able to move on with my project by using the REST API instead (see this post).
... View more
08-09-2025
05:26 AM
|
0
|
0
|
638
|
POST
|
I finally figured it out. Here is some code that does work: import urllib
import urllib.request
import json
from urllib.parse import urlencode
url = '<my_url>/FeatureServer/0/applyEdits'
updates = [
{
"attributes": {"objectid": 2, "is_copied": 0}
}
]
params = dict()
params['updates'] = updates
params['f'] = 'json'
req = urllib.request.Request(url, urlencode(params))
req.data = req.data.encode('utf-8')
response = urllib.request.urlopen(req)
data = json.load(response)
... View more
08-07-2025
11:47 AM
|
2
|
3
|
888
|
POST
|
Does anybody have an Python code example of submitting an applyEdits to the ArcGIS REST API? I'm spending way too much time trying to get a very simple update to work. I tried to use the API for Python but ran into a problem with that so I thought the REST API might work better. I think my problem is how I'm encoding the parameters but not sure. I did a browser trace doing the update manually with the ArcGIS REST Services Directory tool and this is the form data that gets sent - I'm just not sure how to make that happen with Python. adds=&updates=%5B%7B%22attributes%22%3A+%7B%22objectid%22%3A+zz%2C+%22is_copied%22%3A+1%7D%7D%5D&deletes=&gdbVersion=&rollbackOnFailure=true&useGlobalIds=false&returnEditMoment=false&trueCurveClient=true&attachments=&timeReferenceUnknownClient=false&datumTransformation=&editsUploadId=&async=false&returnEditResults=true&f=html
... View more
08-07-2025
06:41 AM
|
0
|
6
|
932
|
POST
|
I'm writing a python script to update a public feature class on my enterprise portal. The edit_features API call hangs then times out with this message *** requests.exceptions.ConnectionError: A connection error has occurred: HTTPSConnectionPool(host='gis.mortonarb.org', port=443): Max retries exceeded with url: /server/rest/services/Hosted/service_d8b3fda9400f4053aa5c90c400d6c07d/FeatureServer/0/applyEdits (Caused by ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))) I can edit the feature class from the item's data tab and also directly in the REST service (anonymously), but it fails using the API. The API works for reading the layer. CRTI_URL = 'https://gis.mortonarb.org/server/rest/services/Hosted/service_d8b3fda9400f4053aa5c90c400d6c07d/FeatureServer/0'
CRTI_FEATURE_LAYER = gis.content.search(CRTI_URL)[0].layers[0]
CRTI_FEATURE_LAYER.edit_features(updates=[{"objectid": 2, "is_copied": 1}]) Any ideas on what might be the problem?
... View more
08-06-2025
09:58 PM
|
0
|
1
|
684
|
POST
|
Unfortunately, I think any literal string can potentially be altered. Using the older python notation such as "hello %s goodbye" % (variable) works better the f string equivalent. It's a constant issue and I've had to go to some extremes to work around the problem - here is one example below where I create variables to represent the strings, then use those variables later on in the code. Of course to create the variable I have to trick the consolidator with the character replacement. FQN = '?qn'.replace('?','f') # fqn
ORG_VIEW = '?rg_view'.replace('?', 'o') # org_view
POLLINATORSCORECARD = '?ollinatorScorecard'.replace('?', 'P') # PollinatorScorecard
MANAGEMENTAREA = '?anagementArea'.replace('?','M') # ManagementArea
CENTERLINE = '?enterline'.replace('?','C') # Centerline
SITE = '?ite'.replace('?','S') # Site
PROGRAM = '?rogram'.replace('?','P') # Program
ORGANIZATION = '?rganization'.replace('?','O') # Organization
... View more
05-09-2025
03:14 PM
|
0
|
0
|
2991
|
POST
|
ESRI support basically punted on this. I was able to work around the problem by adding code to download the images to the local file system then doing the upload from there.
... View more
04-18-2025
12:01 PM
|
0
|
0
|
376
|
POST
|
This is exactly my problem - thanks for finding that issue. I wasn't even aware of that git site's existence
... View more
04-04-2025
01:17 PM
|
0
|
0
|
773
|
POST
|
I've always suspected it was related to the number of shares on the item but could never figure out the threshhold. The item I'm testing with is shared with more than 5 groups. I'm running on API version 2.4.0 and it appears there will be a fix in 2.4.1. I'll do some more testing to verify I'm running into the same problem.
... View more
03-30-2025
05:45 AM
|
0
|
0
|
851
|
POST
|
Due to some item sharing apis being deprecated, I'm updating my code to use the group sharing manager APIs. But I must be doing something totally wrong because when I check the item sharing states via the item -> overview -> share button, the api calls to add and remove the item from the group don't seem to have any effect. I created a notebook (attached) with each step so I can do the sequences of share, test, unshare, test etc in any order. The code is listed below. When I run this from start to finish, the item appears not to be shared with the group. Any ideas on what I'm doing wrong? from arcgis.gis import GIS
gis = GIS("home")
# Initialize item and group variables
ITEM_ID = '747f78beae544888aa58ebf3dd17b258'
print (f"Item: {gis.content.get(ITEM_ID).title}")
GROUP_ID = 'dfedf7528fac409b8d96b0ffb940edd2'
print (f"Group: {gis.groups.get(GROUP_ID).title}")
# Test if the item is shared with the group
print (GROUP_ID in [g.id for g in gis.content.get(ITEM_ID).sharing.shared_with['groups']])
# Unshare the item with group
gis.content.get(ITEM_ID).sharing.groups.remove(gis.groups.get(GROUP_ID))
# Share the item with the group
gis.content.get(ITEM_ID).sharing.groups.add(gis.groups.get(GROUP_ID))
# Print all items shared with the group
print([(i.id,i.title) for i in gis.groups.get(GROUP_ID).content(max_items=9999)])
# Print all groups that the item is shared with
print ([(g.id, g.title) for g in gis.content.get(ITEM_ID).sharing.shared_with['groups']])
... View more
03-29-2025
02:10 PM
|
0
|
3
|
931
|
POST
|
I have had problems also trying to figure out how to programatically overwrite hosted layers too. How did you originally publish the hosted feature layer? According to this page, it looks like if you published it from ArcGIS Pro, then you can only overwrite it from Pro (I suspect that does not include using the python window in Pro). "If you published the hosted feature layer from ArcGIS Pro, you must overwrite the service from ArcGIS Pro." I ran a test using your script and got the same Value Error message (I originally published from layer from ArcGIS Pro). But when I loaded the new data into a ArcGIS Pro map then did Share -> Web Layer -> Overwrite Web Layer it worked.
... View more
03-17-2025
08:30 AM
|
1
|
0
|
959
|
POST
|
Yep - I just opened ESRI Case#03852350. I'll post back here if anything comes out of it
... View more
03-06-2025
06:32 AM
|
1
|
0
|
552
|
POST
|
This may look like a duplicate post, which @Clubdebambos solved. But although that solution worked for updating item thumbnails, my script still fails when trying to update group thumbnails. Unfortunately there appears to be no equivalent "update_thumbnail" method for the group object. I updated my test script to target a group: # To recreate problem
# 1. Update the GROUP_ID variable below to an ArcGIS online group id that you own
# 2. Copy this entire script file and paste it into the ArcGIS Pro (make sure you are signed in)python analysis window, hit enter twice
# 3. Enter run_test()
GROUP_ID = 'e3fb48baf4834208bb545894c3fb7e6a'
from arcgis.gis import GIS
import requests
import os
def test_upload_as_thumbnail (group, path):
try:
group.update(thumbnail = path)
print (f"Upload {path} to {group.id} as thumbnail succeeded")
except Exception as ex:
print (f"Upload {path} to {group.id} as thumbnail failed: {str(ex)}")
return
def test_download (url):
if url.lower().startswith('http'):
try:
requests.get(url).content
print (f"Download {url} succeeded")
except Exception as ex:
print (f"Download {url} failed: {str(ex)}")
return
def run_test():
gis = GIS('pro')
for url in ['http://maps.fieldmuseum.org/apps/ROWHWG/icons/FeatureLayer.png', # this one works
'https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer_600_400.png', # this one fails
'https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer.png']: # this one fails
test_download (url)
test_upload_as_thumbnail(gis.groups.get(GROUP_ID), url)
... View more
03-04-2025
01:53 PM
|
1
|
3
|
605
|
POST
|
Yes! I just tried it myself and it does indeed work. Thanks so much. I'm still curious why it works with one web server but not the other but I'll probably just change my code and move on.
... View more
03-04-2025
12:42 PM
|
0
|
0
|
593
|
POST
|
I have a script that updates ArcGIS Online item thumbnails from images stored on our web server. We moved the images to a different web server and now the updates are failing with 'Could not identify file'. There is no problem accessing the image via URL. When I compare browser network traces accessing it on the old server and the new server I don't see anything obviously different. I expanded the image to 600x400 since that is the recommended minimum size with no luck. I've attached a script that can be run to recreate the problem. I'm planning on opening a ticket with ESRI, but thought I'd post it here first in case anybody has any ideas. I'm running on Python 3.11.10 from ArcGIS Pro 3.4.0 # To recreate problem
# 1. Update the ITEM_ID variable below to an ArcGIS online item that you own
# 2. Copy this entire script file and paste it into the ArcGIS Pro (make sure you are signed in)python analysis window, hit enter twice
# 3. Enter run_test()
ITEM_ID = '758054a99d934a9d9113d8a5faccf456'
from arcgis.gis import GIS
import requests
def test_upload_as_thumbnail (item, url):
try:
item.update(thumbnail = url)
print (f"Upload {url} to {item.id} as thumbnail succeeded")
except Exception as ex:
print (f"Upload {url} to {item.id} as thumbnail failed: {str(ex)}")
return
def test_download (url):
try:
requests.get(url).content
print (f"Download {url} succeeded")
except Exception as ex:
print (f"Download {url} failed: {str(ex)}")
return
def run_test():
gis = GIS('pro')
for url in ['http://maps.fieldmuseum.org/apps/ROWHWG/icons/FeatureLayer.png', # this one works
'https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer_600_400.png', # this one fails
'https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer.png']: # this one fails
test_download (url)
test_upload_as_thumbnail(gis.content.get(ITEM_ID), url) Here is the output I get from the test script: Download http://maps.fieldmuseum.org/apps/ROWHWG/icons/FeatureLayer.png succeeded Upload http://maps.fieldmuseum.org/apps/ROWHWG/icons/FeatureLayer.png to 758054a99d934a9d9113d8a5faccf456 as thumbnail succeeded Download https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer_600_400.png succeeded Upload https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer_600_400.png to 758054a99d934a9d9113d8a5faccf456 as thumbnail failed: Could not identify file Download https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer.png succeeded Upload https://rightofway.erc.uic.edu/wp-content/uploads/FeatureLayer.png to 758054a99d934a9d9113d8a5faccf456 as thumbnail failed: Could not identify file
... View more
03-04-2025
11:33 AM
|
0
|
2
|
617
|
Title | Kudos | Posted |
---|---|---|
1 | 08-11-2025 09:19 PM | |
2 | 08-07-2025 11:47 AM | |
1 | 01-18-2022 07:15 AM | |
1 | 03-17-2025 08:30 AM | |
1 | 03-06-2025 06:32 AM |
Online Status |
Offline
|
Date Last Visited |
08-11-2025
09:11 PM
|