AnsweredAssumed Answered

Whats wrong with my JSON?

Question asked by MikeRay on Jul 20, 2015
Latest reply on Jul 20, 2015 by MikeRay

Hi There,


I'm implementing batch data write for my application however I'm somehow going wrong with the JSON i'm posting to the stream URL...


The JSON looks like this (direct from the debugger): "[{\"Timestamp\":\"2015-07-20T00:00:00+00:00\",\"value\":34.5,\"Good\":true,\"Questionable\":false},{\"Timestamp\":\"2015-07-20T00:20:00+00:00\",\"value\":34.7,\"Good\":true,\"Questionable\":false}]"


However when I post to the URL i get the following error:


  "Errors": [

    "Parameter 'value' is required but was not supplied.",

    "Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'OSIsoft.REST.Models.TimedValueDTO' because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON object (e.g. {\"name\":\"value\"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\r\nPath '', line 1, position 1."




It references types that deserialize nicely from a JSON array... I have a class called WriteValue (it has 4 members for Timestamp, Value, Questionable and Good which are all declared dynamic) and I am using it in a generic list to deserialize (List<WriteValue>) so I had hoped this would be OK.


Is there anything obvious I am doing wrong here?


Thanks for your help,