Select to view content in your preferred language

updateFeatures returning Error: Operation without query criteria is not allowed.

762
0
01-19-2022 01:46 PM
Labels (1)
BanchanaPandey
Regular Contributor

We are trying to invoke updateFeatures rest api method from a java httprequest. The service is in an arcgis enterprise server. 

portal url that will generate the token: https://organization.com/portal/sharing/rest/generateToken

feature service sevice url for updateFeatures: https://organizationservices.com/arcgis/rest/services/DRAFT_EDIT/FeatureServer/0/updateFeatures?

The token generation part is working fine.

The udpate part also returns a 200 message, but the data is not updated and we are seeing "Error: Operation without query criteria is not allowed."

Code Snippets  are posted below.

# Token Generation Part

      map.put(HTTPHandler.URL, https://organization.com/portal/sharing/rest/generateToken/)

      headers = HashMap()

      headers.put('Content-Type', 'application/x-www-form-urlencoded')

      map.put(HTTPHandler.HTTP_HEADERPROPS, headers)

     data = String('username=%s&password=%s&client=%s&referer=%s&expiration=%s&f=%s' % ("username", "password", 'referer', 'https://organizationservices.com/','json' ))

      responseBytes = handler.invoke(map, data)

      response = service.tojsonobject(String(responseBytes, 'UTF-8'))

      accessToken = response.get('token')     

      # Got token

 

BASEURL = https://organizationservices.com/arcgis/rest/services/DRAFT_EDIT/FeatureServer/0/updateFeatures?

      url = URL(BASEURL)

      conn = url.openConnection()

      conn.setRequestMethod("POST")

      conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded")

      conn.setRequestProperty("Accept", "text/plain")

      conn.setDoOutput(True)

      conn.setDoInput(True);

      conn.setUseCaches(False);

      conn.connect()

 

      updateattr = "[{'attributes':{'OBJECTID':24,'PNUM': 'B-999-999','INSTALLEDDATE':1920}}]"

      params = "{'f': 'pjson','token': "

      params1 = accessToken + ",'features':" + updateattr +"}"     

      fullparams = params+ params1      

      postData = String.getBytes(fullparams, StandardCharsets.UTF_8)     

      os.write(postData)

      os.flush()

      os.close();

0 Kudos
0 Replies