I have a Class Meeting
:
public int idMeeting { get; set; }
public DateTime dateTime { get; set; } // DateTime(Int32, Int32, Int32, Int32, Int32, Int32) Jahr, Monat, Tag, Stunde, Minute und Sekunde.
public int idRoom { get; set; }
public int idPerson { get; set; }
public List<Person> participants { get; set; }
and Person
:
public int idPerson { get; set; }
public string firstname { get; set; }
public string lastname { get; set; }
public string phonenumber { get; set; }
public string mailadress { get; set; }
public int idCompany { get; set; }
Requesting with RestSharp i get this from the web service:
[{
"idMeeting":1,
"dateTime":"2017-06-21T19:00:00.531",
"idRoom":1,
"idPerson":1,
"participants":[{
"idPerson":1,
"firstname":"name",
"lastname":"name",
"phonenumber":"0123456789",
"mailadress":"lars.name@name.de",
"idCompany":1
},{
"idPerson":3,
"firstname":"Marvin",
"lastname":"name",
"phonenumber":"012345678910",
"mailadress":"Marvin.name@name.de",
"idCompany":1
}]
},{
"idMeeting":2,
"dateTime":"2017-07-15T17:00:00.531",
"idRoom":1,
"idPerson":3,
"participants":[{
"idPerson":4,
"firstname":"Frederic",
"lastname":"name",
"phonenumber":"012345678910",
"mailadress":"Frederik.name@name.de",
"idCompany":1
},{
"idPerson":1,
"firstname":"Lars",
"lastname":"name",
"phonenumber":"0123456789",
"mailadress":"lars.name@name.de",
"idCompany":1
}]
}]
The request I use is:
var client = new RestClient("http://myserver");
var request = new RestRequest("project/api/meeting/5", Method.GET);
var response2 = client.Execute<List<Modells.Meeting>>(request);
response2
has the json in Content, but the Data is null.
What is the misstake i am not see here?
EDIT: THE entire Person
and Meeting
Class
public class Person
{
public int idPerson { get; set; }
public string firstname { get; set; }
public string lastname { get; set; }
public string phonenumber { get; set; }
public string mailadress { get; set; }
public int idCompany { get; set; }
}
public class Meeting
{
public int idMeeting { get; set; }
public DateTime dateTime { get; set; } // DateTime(Int32, Int32, Int32, Int32, Int32, Int32) Jahr, Monat, Tag, Stunde, Minute und Sekunde.
public int idRoom { get; set; }
public int idPerson { get; set; }
public List<Person> participants { get; set; }
}
Thanks to mjwills
Adding the Line :
request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; };
solved the problem. Looks like it was no correct json I recieved.