1

This is working: (but only date is getting passed to the API)

public async Task ConfirmFLSANotice(string mechNbr, DateTime AcceptedDate)
{
    await PutAsync("confirmflsanotice", mechNbr, AcceptedDate.ToString("yyyy-MM-dd"));
}

Here I am passing just date but I want to pass time also, but no other format is working except this ("yyyy-MM-dd"). I've tried multiple ways.

This is controller code:

[JwtAuthentication]
[Route("api/login/confirmflsanotice/{mechNbr}/{AcceptedDate}/")]
[HttpPut]
public void ConfirmFLSANotice(string mechNbr, DateTime AcceptedDate)
{
    var proxy = DsRegistry.Current.GetService<IUserDsService>();
    proxy.ConfirmFLSANotice(mechNbr, AcceptedDate);
    DsRegistry.Current.CloseService(proxy);
}

I cannot change controller code.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92

2 Answers2

0

You need to send the date in a format that the Binder can interpret. Just pass AcceptedDate.ToString("O") which convert date time to a ISO-8601 and this is the default format to pass date and time from one interface to other.

Also I recommend you to specify the type in the route, this avoids calls with invalid params:

[Route("api/login/confirmflsanotice/{mechNbr:int}/{AcceptedDate:datetime}/")]
Frank
  • 192
  • 9
0

I was able to resolve the issue by passing the ticks and then converting those ticks into datetime on backend side