This is what I'm trying to achieve. I'm trying to serialize my model into a JSON for post request to insert records
{
"Data": [
{
"employee_num": "7812345",
"code": "333",
"startdate": "2020-10-03"
},
{
"employee_num": "2345789",
"code": "444",
"startdate": "2020-10-03"
}
]
}
I'm stuck with this
{
"employee_num": "7812345",
"code": "333",
"startdate": "2020-10-03"
},
{
"employee_num": "2345789",
"code": "444",
"startdate": "2020-10-03"
}
Here is my code
var options = new JsonSerializerOptions
{
WriteIndented = false
};
var jsonString = JsonSerializer.Serialize(Model, options);
Newbie here
new {Data = model}Dataelement/level necessary? Do you have access to the classes used by the api you arePOSTing to?class Model { public string employee_num { get; set; } public string code { get; set; } public string startdate{ get; set; } }Then I used List to add datapublic List<Model> model= new List<Model>(); Model.Add(new Model { employee_num = "1", code = "1", startdate = "1" }