0

I have an Api call like whose signature is like below

[Route("TaskToDo/{userId}/{dateFrom}/{dateTo}")]
public async Task<IActionResult> GetTaskToDo(string userId, DateTime dateFrom, DateTime dateTo)

I can't hit the api call in swagger when i enter date like '13-08-2020' because it assumes that it will expect in DD-MM-yyyy.

What is the best approach to solve this issue.. should i change the method signature and take the datetime in string

or

it should be defined that the api is expected to receive the date in a specific format.

Code one
  • 83
  • 9

1 Answers1

0

You can send the date in ISO Format (2020-08-13T00:00) JsonSerializer can covert this to a valid date time.

To send the date in the URL you have to encode it for example:

2020-08-13T00:00 -> 2020-08-13T00%3A00

Kuechlin
  • 126
  • 3