A quick skills background... Not a full time programmer, proficient enough in Python to get by but VERY new to REST API scripting. So forgive me if there is an easy answer, I am missing something simple or a different approach is warranted.
I am trying to update an existing hosted feature service by using the 'Publish Item' operation using the overwrite=true parameter. (API Reference: ArcGIS REST API - Publish Item).
The following function (minus overwrite param) works perfectly to publish the feature service from an existing geojson item I have already added to Portal. When I add the overwrite parameter, I get the message that a service with that name already exists. Seems like it checks the service name before recognizing the overwrite parameter. Service is not delete protected. Seems simple and straightforward adding of a parameter to the REST call. Resulting URLs from the original publishing POST call and the update call are the same except for '&overwrite=true' is added to the URL.
What am I missing?
Response Message: "Publish error for item 'CMT_Test3.geojson'. Service name 'CMT_Test3' already exists"
def PublishService(Short, itemID, username, token, itemName, publishParams):
publishURL = 'http://{}/portal/sharing/rest/content/users/{}/publish'.format(Short, username)
query_dict = {
'itemID': itemID,
'filetype': 'GeoJson',
'f': 'json',
'token': token,
'overwrite': 'true',
'publishParameters':publishParams}
query_dict['publishParameters'] = json.dumps(query_dict['publishParameters'], sort_keys=False)
request = requests.post(publishURL, data=query_dict)
return request.json()
1 Answer 1
According to ESRI this is a bug in the documentation. Hosted feature services cannot be overwritten. A documentation bug has been logged to remove the 'overwrite' parameter.
Doc Bug number is: BUG-000100370
'overwrite': True
instead of'true'
?