Announcement Announcement Module
Collapse
No announcement yet.
RestTemplate encoding URIs "+" not being encoded correctly. Getting 400 Bad Request Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • RestTemplate encoding URIs "+" not being encoded correctly. Getting 400 Bad Request

    I'm trying to pass an ISODateTimeFormat param e.g. 2012-02-21T00:00:00.000+01:00 in a REST GET request using the RestTemplate
    The URL looks something like this
    .......timeline/bookings?begin={begin}
    If I pass the "begin" parameter as 2012-02-21T00:00:00.000+01:00 then the + is not encoded and tomcat rejects this with a 400 bad request (I've setup tomcat to use UTF-8 URI encoding)

    If I try to encode the param in advance using URIEncoder.encode(begin, "UTF-8") i.e. I pass 2012-02-21T00%3A00%3A00.000%2B01%3A00 this gets encoded again in HttpUrlTemplate.encodeUri which also causes a 400 Bad Request
    If I however just replace the + with "%2B" i.e 2012-02-21T00:00:00.000%2B01:00 then it works fine even though the % is encoded to give 2012-02-21T00:00:00.000%252B01

    Is this a bug or a feature or is there some better way of doing this?

  • #2
    Hi, there is a ticket that comments this subject.

    Comment

    Working...
    X