5

I'm using Dispatch from Scala as follows:

val body = """{"count":5,"requeue":true,"encoding":"auto","truncate":50000}"""
val req = url("http://localhost:4567/api/queues/%2f/myQueue/get").as_!("guest", "guest") << (body, "application/json")

val http = new Http

val resp = http(req as_str)

The %2f gets turned into a /, so it tries to post to /api/queues///myQueue/get rather than to /api/queues/%2f/myQueue/get.

How do I escape this properly?

Urist McDev
  • 498
  • 3
  • 14
Blake
  • 71
  • 4
  • 2
    Could this be a related issue? http://stackoverflow.com/questions/2765782/why-does-java-automatically-decode-2f-in-uri-encoded-filenames – Nat Ritmeyer Jul 15 '13 at 14:03

1 Answers1

1

% sign is used in url encoding. So, %2f gets decoded into /. try it on browser and you will see.

Use %25 to represent % sign. e.g.

val req = url("http://localhost:4567/api/queues/%252f/myQueue/get")
Johnny Everson
  • 8,343
  • 7
  • 39
  • 75