Question

I have trouble to call following web service in android application. http://seba:pl,%5Dd77@www.bjadi.com/administrator/components/com_ivmstore/ivmwebservices/vmcategory.php

I am getting following error in my logcat -

java.io.FileNotFoundException: http://seba:pl,%5Dd77@www.bjadi.com/administrator/components/com_ivmstore/ivmwebservices/ivmsettings.php 09-12 17:32:16.098: W/System.err(1575): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:1162)

please make sure that i am passing username/password in url.

Can anyone guide me how can i achieve it ?

Was it helpful?

Solution

You need to either put your login/password in a header (which is not good because there are methods for that, but it is good because it prevents pre-emptive login issues), like :

String header = "Basic " + Base64.encodeToString(("login" + ":" + "password").getBytes(), Base64.NO_WRAP);
urlConnection.setRequestProperty("Autorization", header);

or, you can use a credential provider, which i don't remember how it works

edit

is should read "Authorization", of course. and the link posted by hwrdprkns contains all the methods to do this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top