Overwriting Hosted Feature Service via REST

1828
1
Jump to solution
10-12-2016 06:38 AM
GregGalligan1
New Contributor

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 the overwrite parameter, I get the message that the 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?

"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()
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
1 Solution

Accepted Solutions
GregGalligan1
New Contributor

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

View solution in original post

0 Kudos
1 Reply
GregGalligan1
New Contributor

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

0 Kudos