Received 400 When attempting to send timestamp as request parameter to my rest API









up vote
0
down vote

favorite












I am trying to send timestamp request parameter via postman to my API which looks like :



@GetMapping(path = "/get-data")
public ResponseEntity<Response<Object>> getTaskStatusList(@RequestParam final Timestamp startDate, @RequestParam final Timestamp endDate)
//Body




My request looks like :



url/get-data?startDate=2018-06-27T19:32:21.158+0530&endDate=2018-06-27T19:32:21.158+0530


And I got following:




"code": 400,
"message": "Invalid value '2018-06-27T19:32:21.158 0530' of type 'String' for parameter 'startDate'. Type 'Timestamp' was expected."










share|improve this question























  • does it work if you declare your controller method parameters as - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime startDate ?
    – Sabir Khan
    Nov 9 at 18:57










  • @SabirKhan I want request params of type Timestamp only..don't want to change the type.
    – Neh94
    Nov 9 at 19:07










  • if your method parameter is java.sql.Timestamp, then value that you are sending is not a valid java.sql.Timestamp value so either send values in format (by using JsonFormat annotation )or change param type to accept ISO date. You can also write custom deserializer .
    – Sabir Khan
    Nov 9 at 19:32















up vote
0
down vote

favorite












I am trying to send timestamp request parameter via postman to my API which looks like :



@GetMapping(path = "/get-data")
public ResponseEntity<Response<Object>> getTaskStatusList(@RequestParam final Timestamp startDate, @RequestParam final Timestamp endDate)
//Body




My request looks like :



url/get-data?startDate=2018-06-27T19:32:21.158+0530&endDate=2018-06-27T19:32:21.158+0530


And I got following:




"code": 400,
"message": "Invalid value '2018-06-27T19:32:21.158 0530' of type 'String' for parameter 'startDate'. Type 'Timestamp' was expected."










share|improve this question























  • does it work if you declare your controller method parameters as - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime startDate ?
    – Sabir Khan
    Nov 9 at 18:57










  • @SabirKhan I want request params of type Timestamp only..don't want to change the type.
    – Neh94
    Nov 9 at 19:07










  • if your method parameter is java.sql.Timestamp, then value that you are sending is not a valid java.sql.Timestamp value so either send values in format (by using JsonFormat annotation )or change param type to accept ISO date. You can also write custom deserializer .
    – Sabir Khan
    Nov 9 at 19:32













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am trying to send timestamp request parameter via postman to my API which looks like :



@GetMapping(path = "/get-data")
public ResponseEntity<Response<Object>> getTaskStatusList(@RequestParam final Timestamp startDate, @RequestParam final Timestamp endDate)
//Body




My request looks like :



url/get-data?startDate=2018-06-27T19:32:21.158+0530&endDate=2018-06-27T19:32:21.158+0530


And I got following:




"code": 400,
"message": "Invalid value '2018-06-27T19:32:21.158 0530' of type 'String' for parameter 'startDate'. Type 'Timestamp' was expected."










share|improve this question















I am trying to send timestamp request parameter via postman to my API which looks like :



@GetMapping(path = "/get-data")
public ResponseEntity<Response<Object>> getTaskStatusList(@RequestParam final Timestamp startDate, @RequestParam final Timestamp endDate)
//Body




My request looks like :



url/get-data?startDate=2018-06-27T19:32:21.158+0530&endDate=2018-06-27T19:32:21.158+0530


And I got following:




"code": 400,
"message": "Invalid value '2018-06-27T19:32:21.158 0530' of type 'String' for parameter 'startDate'. Type 'Timestamp' was expected."







rest spring-boot postman






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 18:53

























asked Nov 9 at 18:46









Neh94

11




11











  • does it work if you declare your controller method parameters as - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime startDate ?
    – Sabir Khan
    Nov 9 at 18:57










  • @SabirKhan I want request params of type Timestamp only..don't want to change the type.
    – Neh94
    Nov 9 at 19:07










  • if your method parameter is java.sql.Timestamp, then value that you are sending is not a valid java.sql.Timestamp value so either send values in format (by using JsonFormat annotation )or change param type to accept ISO date. You can also write custom deserializer .
    – Sabir Khan
    Nov 9 at 19:32

















  • does it work if you declare your controller method parameters as - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime startDate ?
    – Sabir Khan
    Nov 9 at 18:57










  • @SabirKhan I want request params of type Timestamp only..don't want to change the type.
    – Neh94
    Nov 9 at 19:07










  • if your method parameter is java.sql.Timestamp, then value that you are sending is not a valid java.sql.Timestamp value so either send values in format (by using JsonFormat annotation )or change param type to accept ISO date. You can also write custom deserializer .
    – Sabir Khan
    Nov 9 at 19:32
















does it work if you declare your controller method parameters as - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime startDate ?
– Sabir Khan
Nov 9 at 18:57




does it work if you declare your controller method parameters as - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime startDate ?
– Sabir Khan
Nov 9 at 18:57












@SabirKhan I want request params of type Timestamp only..don't want to change the type.
– Neh94
Nov 9 at 19:07




@SabirKhan I want request params of type Timestamp only..don't want to change the type.
– Neh94
Nov 9 at 19:07












if your method parameter is java.sql.Timestamp, then value that you are sending is not a valid java.sql.Timestamp value so either send values in format (by using JsonFormat annotation )or change param type to accept ISO date. You can also write custom deserializer .
– Sabir Khan
Nov 9 at 19:32





if your method parameter is java.sql.Timestamp, then value that you are sending is not a valid java.sql.Timestamp value so either send values in format (by using JsonFormat annotation )or change param type to accept ISO date. You can also write custom deserializer .
– Sabir Khan
Nov 9 at 19:32













1 Answer
1






active

oldest

votes

















up vote
0
down vote













Your timestamp is in a wrong format.



According to this site and ISO-8601, your timestamp should be like:



YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)


Where



YYYY = four-digit year
MM = two-digit month (01=January, etc.)
DD = two-digit day of month (01 through 31)
hh = two digits of hour (00 through 23) (am/pm NOT allowed)
mm = two digits of minute (00 through 59)
ss = two digits of second (00 through 59)
s = one or more digits representing a decimal fraction of a second
TZD = time zone designator (Z or +hh:mm or -hh:mm)


It will probably work then.






share|improve this answer




















  • Have tried it. Still, it treats it as string parameter only instead of timestamp.
    – Neh94
    Nov 9 at 19:05










  • Can't you receive it as a String then parse yourself to Date ou Timestamp?
    – Victor Lengler
    Nov 9 at 19:22










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231662%2freceived-400-when-attempting-to-send-timestamp-as-request-parameter-to-my-rest-a%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













Your timestamp is in a wrong format.



According to this site and ISO-8601, your timestamp should be like:



YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)


Where



YYYY = four-digit year
MM = two-digit month (01=January, etc.)
DD = two-digit day of month (01 through 31)
hh = two digits of hour (00 through 23) (am/pm NOT allowed)
mm = two digits of minute (00 through 59)
ss = two digits of second (00 through 59)
s = one or more digits representing a decimal fraction of a second
TZD = time zone designator (Z or +hh:mm or -hh:mm)


It will probably work then.






share|improve this answer




















  • Have tried it. Still, it treats it as string parameter only instead of timestamp.
    – Neh94
    Nov 9 at 19:05










  • Can't you receive it as a String then parse yourself to Date ou Timestamp?
    – Victor Lengler
    Nov 9 at 19:22














up vote
0
down vote













Your timestamp is in a wrong format.



According to this site and ISO-8601, your timestamp should be like:



YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)


Where



YYYY = four-digit year
MM = two-digit month (01=January, etc.)
DD = two-digit day of month (01 through 31)
hh = two digits of hour (00 through 23) (am/pm NOT allowed)
mm = two digits of minute (00 through 59)
ss = two digits of second (00 through 59)
s = one or more digits representing a decimal fraction of a second
TZD = time zone designator (Z or +hh:mm or -hh:mm)


It will probably work then.






share|improve this answer




















  • Have tried it. Still, it treats it as string parameter only instead of timestamp.
    – Neh94
    Nov 9 at 19:05










  • Can't you receive it as a String then parse yourself to Date ou Timestamp?
    – Victor Lengler
    Nov 9 at 19:22












up vote
0
down vote










up vote
0
down vote









Your timestamp is in a wrong format.



According to this site and ISO-8601, your timestamp should be like:



YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)


Where



YYYY = four-digit year
MM = two-digit month (01=January, etc.)
DD = two-digit day of month (01 through 31)
hh = two digits of hour (00 through 23) (am/pm NOT allowed)
mm = two digits of minute (00 through 59)
ss = two digits of second (00 through 59)
s = one or more digits representing a decimal fraction of a second
TZD = time zone designator (Z or +hh:mm or -hh:mm)


It will probably work then.






share|improve this answer












Your timestamp is in a wrong format.



According to this site and ISO-8601, your timestamp should be like:



YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)


Where



YYYY = four-digit year
MM = two-digit month (01=January, etc.)
DD = two-digit day of month (01 through 31)
hh = two digits of hour (00 through 23) (am/pm NOT allowed)
mm = two digits of minute (00 through 59)
ss = two digits of second (00 through 59)
s = one or more digits representing a decimal fraction of a second
TZD = time zone designator (Z or +hh:mm or -hh:mm)


It will probably work then.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 9 at 18:57









Victor Lengler

535




535











  • Have tried it. Still, it treats it as string parameter only instead of timestamp.
    – Neh94
    Nov 9 at 19:05










  • Can't you receive it as a String then parse yourself to Date ou Timestamp?
    – Victor Lengler
    Nov 9 at 19:22
















  • Have tried it. Still, it treats it as string parameter only instead of timestamp.
    – Neh94
    Nov 9 at 19:05










  • Can't you receive it as a String then parse yourself to Date ou Timestamp?
    – Victor Lengler
    Nov 9 at 19:22















Have tried it. Still, it treats it as string parameter only instead of timestamp.
– Neh94
Nov 9 at 19:05




Have tried it. Still, it treats it as string parameter only instead of timestamp.
– Neh94
Nov 9 at 19:05












Can't you receive it as a String then parse yourself to Date ou Timestamp?
– Victor Lengler
Nov 9 at 19:22




Can't you receive it as a String then parse yourself to Date ou Timestamp?
– Victor Lengler
Nov 9 at 19:22

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231662%2freceived-400-when-attempting-to-send-timestamp-as-request-parameter-to-my-rest-a%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

Syphilis

Darth Vader #20