Reputation: 1188
I wrote the following method to try to diagnose a problem I'm experiencing in my application:
[Route("/api/flow/test"), HttpPost]
[ProducesResponseType(typeof(string), (int)HttpStatusCode.OK)]
public async Task<IActionResult> Test(string id, [FromBody] JToken input)
{
var result = input == null ? "Not OK" : "OK";
return Ok(result);
}
I post a large (6.5MB+) JSON body to it, and in one instance it works fine. When I post a similar JSON with some added properties, it does not - the input
parameter comes in as null
. However, both JSON validate successfully with every tool I've found that can handle their size. Please provide some additional ideas about how to further investigate what is causing the body parameter input to be treated as null.
Upvotes: 0
Views: 42
Reputation: 174397
One option would be to declare it as string
instead of JToken
and try to explicitly parse it in the action body.
This will show you two things:
input
is still empty, it's not a problem with JSON parsingOnly when input
is not null and parsing it in the body works - only then you need to deep dive into what actually happens, when you declare an action parameter as JToken.
Upvotes: 3