I'm attempting to upsert using the append feature service layer REST API but the operation is failing. This is the response from the job query below. Is there any way I can get more diagnostics on which field is incorrect? I've checked all the boolean fields and they seem to be correct. I've triple checked all the other fields as well.
Invalid JSON specified for feature collection. Parse failed - Newtonsoft.Json.JsonReaderException: Error parsing boolean value. Path '', line 1, feature_service_layer.py:63
position 1.
at Newtonsoft.Json.JsonTextReader.ParseTrue()
at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
a
Solved! Go to Solution.
Self-solved, the problem was the "edits" key needs to be encoded as a json string, not a json dict. The documentation does indeed state this but the example provided could be a bit clearer.
before:
url_params = {
"edits": {
"type": "FeatureCollection",
"features": [...],
},
}
after:
url_params = {
"edits": json.dumps({
"type": "FeatureCollection",
"features": [...],
}),
}
Self-solved, the problem was the "edits" key needs to be encoded as a json string, not a json dict. The documentation does indeed state this but the example provided could be a bit clearer.
before:
url_params = {
"edits": {
"type": "FeatureCollection",
"features": [...],
},
}
after:
url_params = {
"edits": json.dumps({
"type": "FeatureCollection",
"features": [...],
}),
}