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

1

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

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);
}

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.