2

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()
  • Have you tried passing 'overwrite': True instead of 'true'? – Evan Oct 13 '16 at 1:36
  • Thanks for the response. Yes I have tried every combination of upper or lower case, single quotes and double quotes. The correct value for JSON Boolean data type is 'true' and I have found examples on the web matching my use of 'overwrite' : 'true' in the dictionary. See line 216 in the following code: link – ggalliga Oct 13 '16 at 14:36
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.