I'm passing some JSON from one Web API to another. Within the 1st API I serialize the object, and the resulting string looks fine. When the call comes into the 2nd API, I'm stepping through the method at the point of deserializing the JSON into an object.
Inside the receiving controller:
string inputs = req.Content.ReadAsStringAsync().Result;
JSON string (inputs variable) looks like this: (yes this is viewed within the Text visualizer):
{"LogEntry":"{\"Id\":0,\"AppName\":\"MyTestController\",\"LogMessage\":\"this is a test\",\"ServerName\":\"dev-test3\",\"LoggedOnDate\":\"2017-06-27T15:37:28.1691783-05:00\",\"LogType\":1}"}
Now after I attempt to deserialize the JSON back into my object (LogEntry) using this:
LogMgr.LogEntry logentry = JsonConvert.DeserializeObject<LogMgr.LogEntry>(inputs);
I am getting null values in the fields of LogEntry.
Here is my POCO class LogEntry:
public class LogEntry
{
public int Id { get; set; }
public string AppName { get; set; }
public string LogMessage { get; set; }
public string ServerName { get; set; }
public DateTime LoggedOnDate { get; set; }
public int LogType { get; set; }
}
Something has gone wrong, but I can't see it. Seems like I've had issues with escape characters in JSON data before.
What can I check for in the deserialization step?