Debugging ApiController requests with System.Text....
# help-with-other
k
Anyone got any tips/ideas for the best way to debug how asp.net deserializes objects when using a ApiController ? my google fu is failing me for this one 😦 I have an object, that i can serialize to json, and in code (using the System.Text.Json serializer) happily deserialize back from that json string - but when i call an ApiController with the json the API controller just gives me back an empty version of the object 😞 I have seen this before and done trial and error to eventually workout what was failing, but this object isn't small, and i would rather get some form of error back from .net when it happens. so just wondering if anyone has any clues
in my case, going back to the request and reading in the body stream in the mothid. helped me debug it. and release i'd missed [FromBody] on the parameter, but not 100% sure why i needed it 😦
i
If it's any consolation Kevin, you're not alone! I've done the same thing myself in the past and been scratching my head over it for ages. Sorry I didn't spot your post earlier.
58 Views