How to use getRequestUri().getRawQuery() in the url on Java escape -
as know url not allow special character there, need encode that: : metadata=[{name: serialnumber, value: aaaaaaaaa},{name: register, value: abcde}]
in url
i tried encode work
string abc= java.net.urlencoder.encode("http://localhost:9080/myapp/myapp/search?metadata=[{name: serialnumber, value: aaaaaaaaa},{name: register, value: abcde}]", "utf-8");
but why fail following if use info.getrequesturi().getrawquery() instead?
public response search(@context final uriinfo info, @context final httpheaders httpheaders) throws exception { string requesturi = java.net.urlencoder.encode(info.getrequesturi().getrawquery(), "utf-8");
error:
caused by: java.net.urisyntaxexception: illegal character in query
how can encode if use info.getrequesturi().getrawquery()
this might due white space in metadata. may either -
- remove white spaces (metadata=[{name:serialnumber,value:aaaaaaaaa},{name:register,value:abcde}]
- replace white spaces + mentioned in question
hope work!
Comments
Post a Comment