C#C
C#3y ago
uselessxp

✅ RestAPI getting an error while testing (TimeSpan related)

I thought to have solved this, but it's not.

As title, I'm testing some written RestAPI (still in development) for a service.
The project is in .NET 7.0
There are few fields to type plus a field that will put in a DB hours and minutes, example 10:00
Well, in the model definition I have this:
public TimeSpan TestHour { get; set; }

Well, when I launch the debug, and it open Swaggler, I type all fields, and finally I have to write this TestHour.
I tried with:
  • 10:00
  • 10:00:00
  • 360000000000
  • 360000000000, 0, 0
    None of those worked, and I get the following error from Swaggler:
    The JSON value could not be converted to System.TimeSpan
Someone knows what could be?
Am I doing something wrong, or maybe something doesn't works with this .NET ver?
Was this page helpful?