title: Error when DeserializeObject to Datetime
body: <p>I'm trying to convert a JSON string to DateTime by getting the date from headers, and encountering an error.</p>
  
  <p>My code: </p>
  
  <pre><code>if (actionContext.Request.Headers.Contains("DataSync"))
  {
      var date = actionContext.Request.Headers.GetValues("DataSync").First();
      userRequest.LastSync =
          JsonConvert.DeserializeObject&lt;DateTime&gt;(date,new IsoDateTimeConverter());
  }
  </code></pre>
  
  <p>Error: </p>
  
  <pre><code>"Message": "An error has occurred.",
  "ExceptionMessage": "Error reading date. Unexpected token: Integer. Path '', line 1, position 2.",
  "ExceptionType": "Newtonsoft.Json.JsonReaderException",
  "StackTrace": " em Newtonsoft.Json.JsonReader.ReadAsDateTimeInternal()\ \ em Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)\ \ em Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\ \ em Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\ \ em Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)\ \ em Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)\ \ em Portal.Infraestructure.Filters.UserRequestFilter.OnActionExecuting(HttpActionContext actionContext) na d:\\Projetos\\api\\Portal\\Infraestructure\\Filters\\UserRequestFilter.cs:linha 28\ \ em System.Web.Http.Filters.ActionFilterAttribute.OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken)\ \ --- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada ---\ \ em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\ \ em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\ \ em System.Web.Http.Filters.ActionFilterAttribute.&lt;ExecuteActionFilterAsyncCore&gt;d__0.MoveNext()\ \ --- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada ---\ \ em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\ \ em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\ \ em System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\ \ em System.Web.Http.Controllers.ActionFilterResult.&lt;ExecuteAsync&gt;d__2.MoveNext()\ \ --- Fim do rastreamento de pilha do local anterior onde a exceção foi gerada ---\ \ em System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\ \ em System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\ \ em System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\ \ em System.Web.Http.Dispatcher.HttpControllerDispatcher.&lt;SendAsync&gt;d__1.MoveNext()
  </code></pre>
  
  <p>I am using postman for testing. I am calling my controller and passing the date in headers on postman.<img src="https://i.stack.imgur.com/bI0xa.jpg" alt="enter image description here">
  What can i do for fix this error?</p>