Results 1 to 3 of 3

Thread: UriTemplate expand method, tries to replace URL parameters containing {} characters

  1. #1
    Join Date
    Oct 2011
    Posts
    2

    Default UriTemplate expand method, tries to replace URL parameters containing {} characters

    Hi there,
    I'm using spring-android 1.0.0.M4 and noticed this behaviour.

    Let's say I want to make a getForObject pointing to following URL:

    protocol://example.com/databases/mydatabse/collections/mycollection?q={"field1":"value1", "field2":"value2"}&apikey=8r2e34gd6d3

    where q it's a json notated query, like mongolab API.

    Well, in this scenario, UriTemplate tries to expand variable "field1":"value1", "field2":"value2" ... which in this case is not a variable, but a URL parameter value.

    Is this an expected behaviour?
    do you plan to support this kind of URL parameters?

    for now, I've made a simple workaround for this, but I'm curious about this kind of URL parameters support.

    thanks!

  2. #2
    Join Date
    Nov 2010
    Posts
    174

    Default

    In this case, this is the expected behavior, because as you noted Rest Template is designed to replace the {param} notation in the url. The easiest workaround for this is to create a String with your JSON data and use that to populate the q={query} part of the url. I could see the benefit of changing the notation used for parameters, since it obviously collides with JSON notation, but that would also break a lot of existing code out there.
    Roy Clarkson
    Spring Mobile Projects Lead

  3. #3

    Default

    mnogo zavano, dobre che nai-nakraq se registrirah, che mnogo se izmachih

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •