I have this piece of code:
var client = new RestClient(fullUri);
var request = new RestRequest(GetMethod(method));
client.UseSerializer(
() => new RestSharp.Serialization.Json.JsonSerializer { DateFormat = "yyyy-MM-dd HH:mm:ss" }
);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
if (body != null)
request.AddJsonBody(body);
var response = client.Execute(request);
if (response.ErrorException != null)
throw response.ErrorException;
return JsonConvert.DeserializeObject<ResponseData>(response.Content);
Note the
client.UseSerializer(
() => new RestSharp.Serialization.Json.JsonSerializer { DateFormat = "yyyy-MM-dd HH:mm:ss" }
);
I have added that code because I need the date format to be yyyy-MM-dd HH:mm:ss
instead of yyyy-MM-ddTHH:mm:ss.zzzzz
(the default)
RestRequest.DateFormat
is obsolete.
When the calling is made, I saw that a date is passed using the default format, instead of the custom one.
How can I do it?