Reputation: 2074
I have an RESTful API call that looks like the following:
http://xxxxx:9000/api/parameter/value?ecosystem_name=streaming_pipeline&ecosystem_key_name=kafka_brokers
Which works fine when I use it through postman or Swagger. When I run scalaj-http on it:
val result = Http("http://xxxxxx:9000/parameter/value").params(Map(("ecosystem_name", "streaming_pipeline"), ("ecosystem_key_name", "kafka_brokers"))).asString
I get a not found response. This has worked with other calls when I use just a single parameter:
val result = Http("http://xxxxxx:9000/api/schemas/name").param("schema_name", schemaName).asString
Why is it when I try and use multiple parameters it seems to be failing? I have tried using .param(...).param(...) instead of the .params with no luck either.
Edit based on:
scala> val result = Http("http://xxxxx:9000/parameter/value").params(Map("ecosystem_name" -> "streaming_pipeline", "ecosystem_key_name" -> "kafka_brokers")).asString
result: scalaj.http.HttpResponse[String] = HttpResponse(,404,Map(Content-Length -> Vector(0), Date -> Vector(Tue, 26 Jul 2016 17:53:49 GMT), Server -> Vector(Apache-Coyote/1.1), Status -> Vector(HTTP/1.1 404 Not Found)))
Upvotes: 0
Views: 1546
Reputation: 4927
I think the problem is that you are not initializing properly the Map[String,String]
parameter for the params
function. The correct way to initialize a Map is:
val myMap = Map(key -> value, key2 -> value2)
So your get request would looks like this:
val result = Http("http://xxxxxx:9000/parameter/value").params(Map("ecosystem_name"-> "streaming_pipeline", "ecosystem_key_name"-> "kafka_brokers")).asString
Upvotes: 1