1

I'm surprised I can't find an answer to this already but I'm trying to export the posted content (in this case json) prior to Deserialization and ModelMapping in a asp.net web api.

I need to do this to debug an issue I'm seeing with the deserialization of the json. This is the exception I'm getting in

Bad JSON escape sequence: \U. Path 'ABCData', line 1, position 2056.

This exception happens within the nested calls starting with:

at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)

I have turned on failed request logging in IIS but this issue happens very sporadically and I'm unable to reliably capture it. So I was hoping that I could just find a way to export the request content every time before it's deserialized. I've also turned on web api logging but it doesn't appear to dump this information.

Is there a simple way to do such a thing?

Corez
  • 314
  • 3
  • 18
  • A tool like fiddler might help you intercept the information once it has left your browser and ensure it is still correct on the way in. http://www.telerik.com/fiddler – Élie Jan 19 '16 at 22:35
  • I'm trying to do this on the server side. The call isn't coming from a browser. – Corez Jan 19 '16 at 22:39
  • Looks like somebody is using an invalid unicode escape sequence in a JSON string. See [how can I Deserialize emoji in json in C#](http://stackoverflow.com/questions/34139312/how-can-i-deserialize-emoji-in-json-in-c-sharp) for how unicode should be correctly escaped. – dbc Jan 19 '16 at 23:15
  • Fidler is a proxy, it will sit inbetween the servers and you can inspect all traffic both ways freely if you like, much like a protocol analyser, but with workflows optimised for web scenarios. It's a little more work than inspecting browser requests, but it is a very capable product. http://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/UseFiddlerAsReverseProxy – Élie Jan 19 '16 at 23:39
  • Yes, someone is sending me invalid json and I'm trying to figure out where in the request it's invalid. I would prefer a solution that dumps exactly the json that will be deserialized within asp.net so that I can just look at corresponding log files or something... – Corez Jan 20 '16 at 00:35

0 Answers0