I'm attempting to send a GET request to the net server in the android device, the server is getting digest authentication enabled, I can authenticate using following kind of code,
HttpHost host = new HttpHost(urlObj.getHost(), -1, null); CredentialsProvider cp = new BasicCredentialsProvider(); cp.setCredentials(scope, creds); HttpContext credContext = new BasicHttpContext(); credContext.setAttribute(ClientContext.CREDS_PROVIDER, cp);
Now my issue is each time after i call httpClient.execute() function it first send request without authentication header after which second time with proper headers. Same with there in whatever way I'm able to instruct HttpClient to transmit authentication particulars automatically?
One of the ways would be to keep last sent request but, I'm also unable to obtain the last sent request. Any suggestion about this?
Thanks ahead of time.
You can utilize HttpURLConnection in order to save all of the params you'll need. I personally use it and display my source code here.
url_connection is determined like this
private HttpURLConnection url_connection // WebService Connection
url_connection= (HttpURLConnection) new URL(your_url_server).openConnection()
url_connection.setRequestMethod("Publish") url_connection.setDoInput(true) url_connection.setDoOutput(true) ....