方法来自官网
需要安装nuget包RestSharp.Newtonsoft.Json
另外调整创建RestClient的代码,将CamelCasePropertyNamesContractResolver参数调整为null
client = new RestClient();
var setting = new JsonSerializerSettings()
{
ContractResolver = null,//new CamelCasePropertyNamesContractResolver(),
DefaultValueHandling = DefaultValueHandling.Include,
TypeNameHandling = TypeNameHandling.None,
NullValueHandling = NullValueHandling.Ignore,
Formatting = Formatting.None,
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
};
client.UseNewtonsoftJson(setting);
[参考]
restsharp