I have this classes:
public class EncuestaRespuesta
{
public string idCaso { get; set; }
public string tipoEncuesta { get; set; }
public string codMovimiento { get; set; }
public string motivoRetirada { get; set; }
public string duracion { get; set; }
public DateTime fechaHora { get; set; }
public string gestor { get; set; }
public List<RespuestasEncuesta> listRespuestasEncuestas { get; set;}
}
public class RespuestasEncuesta
{
public string pregunta { get; set; }
public string respuesta { get; set; }
public string numOrdenTrabajo { get; set; }
}
Using JSON.NET,
// https://www.newtonsoft.com/json/help/html/NullValueHandlingIgnore.htm
var settings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
};
settings.Converters.Add(new Newtonsoft.Json.Converters.IsoDateTimeConverter());
var json = JsonConvert.SerializeObject(request, Formatting.Indented, settings);
When I call REST API (HttpClient PostAsync
), I get the error:
"The server committed a protocol violation. Section=ResponseStatusLine" Error: ServerProtocolViolation
I don't why. My JSON string:
{
"idCaso": "5009E000007Hp94QAD",
"codMovimiento": "1",
"motivoRetirada": "2",
"duracion": "0",
"fechaHora": "2018-03-20T12:56:36.4841861Z",
"gestor": "GESTOR SALESFORCE",
"tipoEncuesta": "T3_1018_RM",
"listRespuestasEncuestas": [
{
"numOrdenTrabajo": "",
"pregunta": "",
"respuesta": ""
}
]
}
I would like this JSON string, is OK in my tests:
{
"idCaso": "5009E000007Hp94QAC",
"codMovimiento": "1",
"motivoRetirada": "1",
"duracion": "",
"fechaHora": "2018-02-06T14:40:43.511Z",
"gestor": "",
"tipoEncuesta": "T3_1018_RM",
"listRespuestasEncuestas": [
{
"numOrdenTrabajo": "",
"pregunta": "",
"respuesta": ""
}
]
}
Issue: The dateTime field:
"fechaHora": "2018-03-20T12:56:36.4841861Z",
is wrong
"fechaHora": "2018-02-06T14:40:43.511Z"
is OK
Any suggestions?