fail to update AGOL Feature Error 400

138
1
Jump to solution
12-09-2021 08:11 AM
StuartMoore
Occasional Contributor III

i'm trying to read a polygon feature in AGOL do some things and then set a attribute to complete but for some reason i get an error when trying apply the updates, ive re-used some code that has worked on a different FS but i'm stumped

can anyone see what i have missed....

from arcgis.gis import GIS
import os
gis = GIS("home")
bobFS = gis.content.get("5xxxxxxxx9")
bobFS_Area = bobFS.layers[0]
bobFS_Area_Filter = bobFS_Area.query(where = "objectid = 3")
for bob in bobFS_Area_Filter:
    print (bob.attributes['OBJECTID'])
    print(bob.attributes['SurveyStatus'])
    bob.attributes['SurveyStatus'] = 'Comp'
    bobFS_Area.edit_features( updates=[bob])
    print("Done")

results

3
Met
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
In  [78]:
Line 5:     bobFS_Area.edit_features( updates=[bob])

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\features\layer.py, in edit_features:
Line 2827:  return self._con.post_multipart(path=edit_url, postdata=params)

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\gis\_impl\_con\_connection.py, in post_multipart:
Line 868:   force_bytes=kwargs.pop("force_bytes", False),

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\gis\_impl\_con\_connection.py, in _handle_response:
Line 625:   self._handle_json_error(data["error"], errorcode)

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\gis\_impl\_con\_connection.py, in _handle_json_error:
Line 648:   raise Exception(errormessage)

Exception: 
Field Street_hyper has invalid html content.
(Error Code: 400)
---------------------------------------------------------------------------
0 Kudos
1 Solution

Accepted Solutions
StuartMoore
Occasional Contributor III

 

i'll answer my own question... such a simple mistake...

you need to specify the out fields...

bobFS_Area_Filter = bobFS_Area.query(where = "objectid = 3",out_fields="objectid, SurveyStatus")

 

View solution in original post

0 Kudos
1 Reply
StuartMoore
Occasional Contributor III

 

i'll answer my own question... such a simple mistake...

you need to specify the out fields...

bobFS_Area_Filter = bobFS_Area.query(where = "objectid = 3",out_fields="objectid, SurveyStatus")

 

0 Kudos