Select to view content in your preferred language

applyEdits "updates" Error 500

862
3
Jump to solution
04-11-2023 01:38 PM
JamesCrandall
MVP Frequent Contributor

Enterprise v10.9.1  (federated)

ArcPro 2.9.7

Python 3.x

 

For some reason when submitting requests to a feature service's applyEdits task, it doesn't like the updates payload when executed from a .py script source.  However, if I print that payload and copy./paste it into the feature service's REST endpoint interface it successfully applies the update.

 

Sample:

{'f': 'json', 'updates': [{'attributes': {'OBJECTID': 493680, 'REVIEW_STATUS': 'REVIEW', 'PERMIT_ID': '', 'PERMIT_TYPE': 'ERP', 'PERMIT_SUBTYPE': 'IND', 'PROJECT_NAME': 'GROVE LAND', 'APP_NO': '509-107', 'PERMIT_NO': '', 'geometry': {'rings': [[[850428.7066254951, 1107318.8247719035], [851334.0043555796, 1107319.7210955694], [851357.1526032463, 1106852.254182741], [850441.3657209128, 1106858.234485738], [850428.7066254951, 1107318.8247719035]]]}}], 'token': 'validTokenAppendedHere'}

 

Again, copying pasting the above into the REST endpoint updates parameter input works.  However, when executed from the python script it fails with error message:

 

{'error': {'code': 500, 'message': 'Unable to complete operation.', 'details': ["No edits ('adds', 'updates', 'deletes', or 'attachment edits') were specified."]}}

 

0 Kudos
1 Solution

Accepted Solutions
JamesCrandall
MVP Frequent Contributor

The applyEdits wants the updates parameter array to be in quotes.

From:

updates.append(dict)
params = {'f': 'json','updates': updates,'token': tok}

 

To:

updates.append(dict)
params = {'f': 'json','updates': '{}'.format(updates),'token': tok}

View solution in original post

0 Kudos
3 Replies
AnthonyRyanEQL
Regular Contributor

Can you post your python code that sends the applyEdits to the service?

0 Kudos
JamesCrandall
MVP Frequent Contributor

Thanks for taking a look!  

 

def getGeometry(oid, url):

    params = {'f': 'json',
              'objectIds': oid,
              'outFields': '*',
              'returnGeometry': 'true',
              'token': tok}

    r = requests.post("{}/query".format(url), data = params, verify=False)
    response = json.loads(r.content)
    if r.status_code==200:
        appCount = (response['features'])

        if len(appCount) > 0:
            return response
        else:
            return 0

    else:
        return 0

def update_egisScratch(oid):

    try:

        updates = []

        dict = {'attributes' : {
                'OBJECTID' : oid,
                'REVIEW_STATUS' : inputStatus,
                'PERMIT_ID': inputPermitId,
                'PERMIT_TYPE': inputPermitType,
                'PERMIT_SUBTYPE': inputPermitSubType,
                'PROJECT_NAME': inputProjectName,
                'APP_NO': inputAppId,
                'PERMIT_NO': inputPermitId,
                'APP_ID': inputAppId}
                }


        jsonResult = getGeometry(oid, queryURL_egisSCRATCH)

        #get the geometry from the getGeometry() function for our new payload
        geom = jsonResult['features'][0]['geometry']
        dict.update({'geometry': geom})

        if not jsonResult == 0:

            updates.append(dict)
            params = {'f': 'json',
                      'updates': updates,
                      'token': tok}

            url = "{}/applyEdits".format(queryURL_egisSCRATCH)
            print (params)
            r = requests.post(url, data=params, verify=False)
            response = json.loads(r.content)
            print (response)

 

 

0 Kudos
JamesCrandall
MVP Frequent Contributor

The applyEdits wants the updates parameter array to be in quotes.

From:

updates.append(dict)
params = {'f': 'json','updates': updates,'token': tok}

 

To:

updates.append(dict)
params = {'f': 'json','updates': '{}'.format(updates),'token': tok}
0 Kudos