1
|
request.AddParameter("application/json", jsonStr, ParameterType.RequestBody);
|
Somtimes when you use
1
|
request.AddJsonBody(object);
|
to add Json body will result in data losing.
eg.
A Class like this
1
2
3
4
5
6
|
public class ReportMessage
{
public string reportName {get;set;}
public string dataSetName {get;set;}
public List<dynamic> data {get;set;}
}
|
may be serialized to
1
2
3
4
|
{\"reportName\":\"aaa.frx\",
\"dataSetName\":\"data\",
\"data\":[\"filed1\":\"field1data\",\"field2\":\"field2data\"}]
}
|
or
1
2
3
4
5
6
7
|
{"reportName":"aaa.frx",
"dataSetName":"data",
"data":[{"filed1":"field1data","field2":"field2data"},
{"filed3":"field1data","field4":"field2data"},
{"filed5":"field1data","field6":"field2data"}
]
}
|
when I POST that to a Nancy Host using PostMan or Fiddler, it can be deserilized OK. But When Post it using RestSharp with AddJsonBody, then
1
2
3
4
5
6
|
{"reportName":"aaa.frx",
"dataSetName":"data",
"data":[
{},{},{}
]
}
|
the data disappeared.