2

I have

@PUT
@Path("{id}")
public Response modify(@PathParam("id") Integer id, 
                       @QueryParam("user") String user, @QueryParam("time") Date time) {....

I am trying to use RestClient to call this web service (the above is actually a cut down version of what I have)

When I call

..../123?user=user1

I hit the web service. As soon as I add time I get a 403 Forbidden message

..../123?user=user1&time=2013-09-10T20:00:00Z

Even if I pass nothing into the time query parameter I get the 403.

Is there anything difference about passing the java dates?

Thank in advance

RNJ
  • 15,272
  • 18
  • 86
  • 131
  • Have a look at this this question and accepted solution : http://stackoverflow.com/questions/9520716/cxf-jaxrs-how-do-i-pass-date-as-queryparam – Jayaram Sep 10 '13 at 10:18

3 Answers3

2

It's not able to deserialize the String to a Date. Two options are either you can modify the date string as accepted by the date class or use another form, such as a long value.

blackpanther
  • 10,998
  • 11
  • 48
  • 78
hanish.kh
  • 517
  • 3
  • 15
0

One observation: It seems you are adding an extra slash(/) before your query params:

change this

..../123/?user=user1&time=2013-09-10T20:00:00Z

to

..../123?user=user1&time=2013-09-10T20:00:00Z

Second thing is that you may have to encode your URL to send the date properly to server

Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136
0

Very late to the Party !! But I think this will help others
I was able to make it work by changing Date to LocalDateTime and using @DateTimeFormat

Worked fine with this requestURI

/test/123?user=user1&time=2013-09-10T20:00:00Z

@GetMapping(value = "/test/{id}")
    public ResponseEntity<String> modify(@PathParam("id") Integer id,
            @RequestParam(name = "user", required = false) String user,
            @DateTimeFormat(iso = ISO.DATE_TIME) @RequestParam("time") LocalDateTime date) {
    System.out.println(date);
}

Jay Yadav
  • 236
  • 1
  • 2
  • 10
  • DateTimeFormat is an annotation specific to Spring, which you do not mention in your answer. The question seems to be about generic Java EE/Jakarte EE. – MrThaler Jul 28 '23 at 09:37