I send some request with Deferred Date to a server. The POST request looks like:
{
"text":"texst",
"deferred_date":"2019-09-14 14:00"
}
I send it via Postman or the Unirest in Java and have a 201 Accepted result. The server stores this date value in "2019-09-14T14:00:00+03:00" format.
Since I modify my Date in Java, the final Data is stored in a String
YYYY-MM-dd hh:mm format
DateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd hh:mm");
String deferredTime = "";
deferredTime = dateFormat.format(oldTime);
My original Unirest's POST has the next body construction:
.body("{\"text\":\"...\",\"deferred_date\":\"2019-09-14 06:03\"}")
and it works fine, but if I use my deferredTime String in my POST:
.body("{\"text\":\"...\",\"deferred_date\":\"" + deferredTime + "\"}")
I receive a 400 Bad Request error
{
"userMessage":"Invalid input.",
"errorCode":"invalid",
"fields":{
"deferred_date":[
"Posting date Date has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm[:ss[.uuuuuu]][+HH:MM|-HH:MM|Z]."
]
},
"internalMessage":"Invalid input."
}
I don't understand why it doesn't work if the deferredTime String variable keeps the same "YYYY-MM-dd hh:mm" value as I used before. Any suggestions?