Why RestSharp serializes date time property with utc format

Viewed 1083

I am using something like this.

public class Program
    {
        public static void Main(string[] args)
        {

            RestCustomRequest rt= new RestCustomRequest();
            rt.Test =DateTime.Now.ToString();
            rt.testDate = DateTime.Now;

            string x = ExecuteRestAPI(rt,"");

            //Your code goes here
            Console.WriteLine(x);

        }

      public static string ExecuteRestAPI(RestCustomRequest request,string BaseURL)
      {
        RestRequest apiRequest = new RestSharp.RestRequest();
        apiRequest.RequestFormat = DataFormat.Json;
        apiRequest.AddHeader("Content-Type", "application/json");
        apiRequest.AddBody(request);
        var x = Newtonsoft.Json.JsonConvert.SerializeObject(apiRequest);
        return x;
        RestClient rc = new RestClient(BaseURL);
        IRestResponse resp = rc.Execute(apiRequest);


      }

    }

public class RestCustomRequest
{
  public string Test {get;set;}
  public DateTime testDate{get;set;}
} 

below data shows the issue with restsharp serialization

 {
            "Name": "application/json",
            "Value": "{\"Test\":\"3/24/2016 10:33:35 AM\",\"testDate\":\"2016-03-24T05:03:35.8288773Z\"}",
            "Type": 4,
            "ContentType": null
        },

However if we do AddObject() instead of AddBody() it works. How AddBody() differs from Addobject()

0 Answers
Related