AnsweredAssumed Answered

Can't use webscript with ticket

Question asked by nm_santos on Jun 5, 2012
Latest reply on Jun 5, 2012 by nm_santos
Hi everyone,

I'm using HTTPClient by apache.

I can't seem to use any web scripts, I tried with the JavaDir from the documentation, and it doesn't work.

Here's how I'm doing it:

HttpClient client = new DefaultHttpClient();
      
      HttpGet httpget = new HttpGet("http://localhost:8080/alfresco/service/api/login?u=nuno&pw=*****");
      
      System.out.println("executing request " + httpget.getURI());

The response is for example, this:

<?xml version="1.0" encoding="UTF-8"?>
<ticket>TICKET_606b17d58d32cecfce804685b6c33509093df60a</ticket>

And then, to access the web script I tried:

http://localhost:8080/alfresco/service/javadir/Company%20Home?verbose=true?alf_ticket=606b17d58d32cecfce804685b6c33509093df60a
http://localhost:8080/alfresco/service/javadir/Company%20Home?verbose=true?alf_ticket=TICKET_606b17d58d32cecfce804685b6c33509093df60a
But I get:

Exception in thread "main" org.apache.http.client.HttpResponseException: Unauthorized
   at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:68)
   at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:54)
   at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1070)
   at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1044)
   at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1035)
   at HTTPTest.main(HTTPTest.java:61)

What am I doing wrong?

Regards,
Nuno.

Outcomes