In my Vapor 3 app, I have an Event
model, which has the properties startDate: Date
and endDate: Date
.
Now, I'm wondering how to pass those date values in a POST request. In Postman, I tried the following in x-www-form-urlencoded
:
startDate -> 2019-03-14
This returns the error below:
Could not convert to
Double
: str(\"2019-03-14\")
Apparently, Date
turns into Double
.
So, instead, what value do I need to pass?
I know, that, in Postman, I can insert {{$timestamp}}
, but 1) this doesn't answer my question when using the API outside Postman and 2) this doesn't allow me to enter a date other than now.
I realized that the Date
object is returned in the following format when queried:
2021-12-31T14:29:00Z
So this is what I tried to pass and that worked! No need for any custom decoding.