var connection = url.openConnection();
connection.setRequestProperty("Authorization", "Basic " +
"SWRlbnRpdHlNZ210OjZDamRjM1dk'");
connection.connect();
var stream = connection.getInputStream();

iceman3 <iceman3@no-mx.forums.novell.com> wrote:

>

Hello,
> I am trying to do a getURL call much like shon did in a previous post

however I need to pass through Basic Authentication parameters in order
to authenticate to the web service.
> I keep getting HTTP 401 errors and wondered if anyone has any ideas on

this as I am still getting HTTP 401 errors with the below code. The url
is in a global variable that I pass into the ECMA call and the url is
https://<site name>?<the base 64 encryption or usernameassword>
> Thanks.
> function urlGet(urlString) {
>
>
> try {
> var charset="UTF-8";
> var param1 = java.net.URLEncoder.encode("IdentityMgmt", "UTF-8");
> var param2 = java.net.URLEncoder.encode("6Cjdc3Wd", "UTF-8");
> var query = ("username=%s&password=%s", param1, param2);
>
>
> var url = new java.net.URL(String(urlString));
> stream.setRequestProperty("Authorization", "Basic " +

"SWRlbnRpdHlNZ210OjZDamRjM1dk'");
> var stream = url.openStream();
> var reader = new java.io.InputStreamReader(stream);
> var sb = new java.lang.StringBuilder();
> var c;
> while ((c = reader.read()) != -1) {
> sb.append(String.fromCharCode(c));
> }
> return sb.toString();
> } catch(e) {
> return e.toString();
> }
> }



--
iceman3
------------------------------------------------------------------------
iceman3's Profile: http://forums.novell.com/member.php?userid=64396
View this thread: http://forums.novell.com/showthread.php?t=455992

>