I am trying to invoke a Rest API using akka http client using below code.
val httpRequest = HttpRequest(
method = HttpMethods.GET,
uri ="https://example.com/customers/~/profiles/dj2bQryHPCj4IVrc48xTPD%2Bhswk%2FqNWx%2BLuUA0G2T6GLnyBVD6wC231IjgDBYJnt/preferences",
headers = List(Accept(MediaRange(MediaTypes.`application/json`.withParams(Map("v" → "3")))),
RawHeader("Content-Type", "application/json;v=3"),
RawHeader("Api-Key", "XYZ")
)
)
Http().singleRequest(httpRequest, GatewayHelper.connectionContext)
Before the call goes out, when i check the httprequest.uri (through debugger), there is a partial uri decoding that is happening (%2B changed to +) dj2bQryHPCj4IVrc48xTPD+hswk%2FqNWx+LuUA0G2T6GLnyBVD6wC231IjgDBYJnt
Because of this the API is returning an error. Is there option where we can make akka not tamper with the URI?
I have not tried this but Spray
and akka-http
have some configuration options to modify the strictness of the URIs.
Take a look to this: http://doc.akka.io/docs/akka/2.4.10/scala/http/configuration.html#akka-http
The following parameter
Sets the strictness mode for parsing request target URIs.
# The following values are defined: # # `strict`: RFC3986-compliant URIs are required, # a 400 response is triggered on violations # # `relaxed`: all visible 7-Bit ASCII chars are allowed # uri-parsing-mode = strict
You might want to change it to relaxed
and test again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.