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."
rest spring-boot postman
add a comment |
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."
rest spring-boot postman
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 isjava.sql.Timestamp
, then value that you are sending is not a validjava.sql.Timestamp
value so either send values in format (by usingJsonFormat
annotation )or change param type to accept ISO date. You can also write custom deserializer .
– Sabir Khan
Nov 9 at 19:32
add a comment |
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."
rest spring-boot postman
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
rest spring-boot postman
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 isjava.sql.Timestamp
, then value that you are sending is not a validjava.sql.Timestamp
value so either send values in format (by usingJsonFormat
annotation )or change param type to accept ISO date. You can also write custom deserializer .
– Sabir Khan
Nov 9 at 19:32
add a comment |
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 isjava.sql.Timestamp
, then value that you are sending is not a validjava.sql.Timestamp
value so either send values in format (by usingJsonFormat
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 validjava.sql.Timestamp
value so either send values in format (by usingJsonFormat
annotation )or change param type to accept ISO date. You can also write custom deserializer .– Sabir Khan
Nov 9 at 19:32