lolo xoxo
lolo xoxo

Reputation: 69

I can't parse DateOnly type in .net 7 web api

I have POST endpoint which receives an object with DateOnly field. I've tried to use https://github.com/maxkoshevoi/DateOnlyTimeOnly.AspNet package but didn't resolve my issue. still getting The JSON value could not be converted to DateOnly error

this is the payload :

[
  {
    "startDate": {
      "year": 2023,
      "month": 5,
      "day": 29,
      "dayOfWeek": 1
    },
    "name": "string",
    "endDate": {
      "year": 2023,
      "month": 11,
      "day": 1,
      "dayOfWeek": 2
    }
  }
]

and POST method :

[HttpPost("Save")]
public async Task<IActionResult> Save([FromBody] IEnumerable<Data> Data)
{
       // some logic

        return Ok();
}

Upvotes: 0

Views: 1181

Answers (1)

egallagher1
egallagher1

Reputation: 1

after half an hour of bashing my head against the wall, updating NuGet packages, removing, etc, a simple close and then reopen of VSCode did the trick. I was able to do GET requests but not POST requests so seemed odd but all sorted

Upvotes: 0

Related Questions