Select to view content in your preferred language

Invalid JSON specified for feature collection

223
1
Jump to solution
07-02-2024 01:16 PM
Labels (1)
AaronFrantisak
New Contributor

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

0 Kudos
1 Solution

Accepted Solutions
AaronFrantisak
New Contributor

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": [...],
  }),
}

 

View solution in original post

1 Reply
AaronFrantisak
New Contributor

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": [...],
  }),
}