web services - Java : How to avoid hand-shake mode with HttpURLConnection authentication? -


i calling rest web service httpurlconnection (this not actual url , credentials, of course changed values before posting on public forum)...

        string uri = "http://99.82.36.238:8443/media/crowd?";         string query = string.format("office_code=%s&content_type_code=%s",                  urlencoder.encode("usa"), urlencoder.encode("sgv"));          httpurlconnection conn = (httpurlconnection) url.openconnection();         conn.setrequestmethod("get");         conn.setrequestproperty("accept", "text/xml");          string username = "usernewbie";         string password = "password";         conn.setrequestproperty("authorization",   credentialsencoder.usernamepasswordbase64(username,password));          if (conn.getresponsecode() != 200) {             throw new runtimeexception("failed : http error code : "                     + conn.getresponsecode() + " because " + conn.getresponsemessage());         }          bufferedreader br = new bufferedreader(new inputstreamreader(                 (conn.getinputstream()))); 

the problem service calling not work in hand-shake mode. meaning needs me send creds first time request made, rather making request , getting 403 , sending cred.

can suggest how modify above code meet requirement?

thanks.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -