AnsweredAssumed Answered

Url authentication with ticket

Question asked by lfo on May 14, 2008

I developpe a webscript which return a list a documents.

When i run my code all is OK for the  url1 part :-) whitch try to call a webscript

For the url2, whitch try to call a document (the url is render by the url1 webscript), i have the "conn 2 OK" but not the second OK message, i get an error : Server returned HTTP response code: 401 for URL: http://localhost:5900/alfresco/service/api/node/content/workspace/SpacesStore/40495a69-1c3b-11dd-a188-f170301757eb/Doc1.htm&alf_ticket=TICKET_1f171e2bd6856acdc8836063c3714587aee152ae
   at com.test.Test.main(

When i try the url2 in my browser, i have a form to connect me and after authentication its ok i can see my document, but i can get it with my code

can anybody tell me why , and where is my mystake?

thanks you very much for your help

Have a nice day


My code

AuthenticationUtils.startSession("admin", "admin");
         System.out.println("auth OK");
         String ticket = AuthenticationUtils.getTicket();

         // ******* URL 1 PART ***********
         URL url1 = new URL("http://localhost:5900/alfresco/service/asir/documents_list/myDocumentsListApp?myDirectory=Company%20Home/User%20Homes&myCategory=Consultant&format=text" +
         URLConnection conn1 = url1.openConnection();
         System.out.println("conn 1 OK");
         BufferedReader br1 = new BufferedReader(new InputStreamReader(conn1
         String line;
         while ((line = br1.readLine()) != null) {            
         // ******* URL 2 PART ***********
         URL url2 = new URL(
               "http://localhost:5900/alfresco/service/api/node/content/workspace/SpacesStore/40495a69-1c3b-11dd-a188-f170301757eb/Doc1.htm" +
         URLConnection conn2 = url2.openConnection();
         System.out.println("conn 2 OK");
         BufferedReader br2 = new BufferedReader(new InputStreamReader(conn2
         System.out.println("InputStream conn  2 OK");
         while ((line = br2.readLine()) != null) {