My application should send a https GET request.
Every time I get an exception from it. If I uncomment url = "http://www.example.com" it works perfect. Otherwise it throws an exception “Illegal character in scheme at index 3“.
How to fix it?
public class TestHttpManager {
private final static String mask= "httрs://%s/action/?key=%s¶m1=%s¶m2=%s¶m3=%s";
public static void Send() throws IOException, URISyntaxException {
if (....)
url = String.format(UrlMask, "anyHostName.com", "keyTest", "param1", "param2", "param3");
//url = "http://www.example.com";
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
request.setURI(new URI(url));
client.execute(request);
}
}
UPDATE: I have an error Tagret host must not be null, or set in parameters too.
You have done
url = "http://www.example.com"+stringOfParameter;now use this function to well format the above
url,and now use the formatted url.
EDIT :
In your case you got
httрs://serverName.com/action/key=myKey¶m1=param1¶m2=param2¶m3=param3with mask, I dont know much about that, but you can do
and then use the above answer.