Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Jtoken as Post Parameter in aspnet Core 3.1

$
0
0

I have an application that was written in aspnet core 2.1 and I did an upgrade to core 3.1 the web API failed.  Why is JToken now not valid parameter?  

// This works on core 2.1 but failed on 3.1

[HttpPost]
public async Task<IActionResult> PostAsync([FromBody] JToken value)
{  

// code here

  return Ok();

}

// This works with Core 3.1

[HttpPost]
public async Task<IActionResult> PostAsync([FromBody] JObject jvalue)
{

// code here

return Ok();

}

//error return 

{"errors":{"":["Unexpected character encountered while parsing value: {. Path '', line 1, position 1."]},"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"|8ab7b30f-40b939694d56c1ec."}


Viewing all articles
Browse latest Browse all 9386

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>