The Input Does Not Contain Any JSON Tokens When Trying to Update Using API

When trying to update (using PUT) through rest api in .net core 3.1 I’m getting:

The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0.

This only happens when trying to update though the production website, locally it works fine. As a test I stripped things back to the bare essentials by creating a new .net core project and using their default example api controller (WeatherForecastController), I added a new update method:

 public IActionResult Update([FromBody]WeatherForecast weatherForecast)
      return Ok();

I published the project (with only that change) and found that I still get the same error when testing through postman. It seems like the problem is possibly on the host’s side and I’ve already raised a support ticket with them, but they were unable to help. Unfortunately I have absolutely no idea how to debug this issue, I have no idea where or what is trying to deserialise the json and consequently failing. Any help would be greatly appreciated.

P.S. If it helps, in postman I’ve set body to “raw” and “json”. I’m fairly certain that the json I’m sending is okay as it works locally.

P.P.S. Hotpots works without any issues.

This Post Has One Comment

  1. No Fault

    I’ve solved this issue by changing the setting ASP.NET: “4.0 to “4.0” in the web host control panel. HTTP Put seems to work fine now.

    I have no idea why it worked and would be interested to hear any suggestions.

Leave a Reply