我是连接到一个API通过Get调用使用喷雾客户端。以下是这方面的代码:
val response = HttpDialog(URI)
.send(Get(String.format("message=%s",message)))
.end我上面的信息是“Hi%20!@#$%,:().?~`”
但是在连接的时候,我得到了IllegalUriException。甚至尝试在conf文件中使用uri解析模式=松弛的原始查询。
以下是堆栈跟踪:
spray.http.IllegalUriException: Illegal URI reference, unexpected character
',' at position 128:
URI?message=Hi%20!@#$%,:().?~`
at spray.http.Uri$.fail(Uri.scala:775) ~[spray-http_2.11-1.3.2.jar:na]
at spray.http.parser.UriParser.complete(UriParser.scala:429) ~[spray-
http_2.11-1.3.2.jar:na]
at spray.http.parser.UriParser.parseReference(UriParser.scala:60) ~[spray-
http_2.11-1.3.2.jar:na]
at spray.http.Uri$.apply(Uri.scala:231) ~[spray-http_2.11-1.3.2.jar:na]
at spray.http.Uri$.apply(Uri.scala:203) ~[spray-http_2.11-1.3.2.jar:na]
at
spray.httpx.RequestBuilding$RequestBuilder.apply(RequestBuilding.scala:36) ~
[spray-httpx_2.11-1.3.2.jar:na]
at
spray.httpx.RequestBuilding$RequestBuilder.apply(RequestBuilding.scala:34) ~
[spray-httpx_2.11-1.3.2.jar:na]发布于 2015-07-21 12:02:34
因为您在查询和片段位置中使用禁止的符号。转换为urlencoded ( Hi%2520!%40%23%24%25%2C%3A().%3F%7E%60 )会有所帮助。
https://stackoverflow.com/questions/31535932
复制相似问题