I am trying to deserialize an API response to a class object. But I get the error:
DateTime content 2017-11-15T10: 00: 00 does not start with \ / Date (and not ending) \ /, which is required for JSON.
My Code:
client.BaseAddress = new Uri(APP_URL);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(APPLICATIONJSON));
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(List<HttpConference>));
HttpResponseMessage response = client.GetAsync(GET_ALL_CONFERNECES).Result;
response.EnsureSuccessStatusCode();
System.IO.Stream svar = response.Content.ReadAsStreamAsync().Result;
List<HttpConference> model = (List<HttpConference>)serializer.ReadObject(svar);
In the database I am using datetime
.
The Json response:
[
{
"ID": 1,
"Namn": "Conference Microsoft",
"StartDatum": "2017-11-15T10:00:00",
"SlutDatum": "2017-11-15T12:00:00",
"KonferensID": null
},
{
"ID": 2,
"Namn": "föreläsning",
"StartDatum": null,
"SlutDatum": null,
"KonferensID": null
}
]
this is the errormessage thrown by the code:
'svar.WriteTimeout' threw an exception of type 'System.InvalidOperationException'
I get an error at the ReadAsStreamAsync:
EDIT
ReadTimeout = 'reply.ReadTimeout' threw an exception of type 'System.InvalidOperationException'
found this article that talks about this problem. But I didn't know how to implement it in my code. Any ideas?