cancel
Showing results for 
Search instead for 
Did you mean: 

Can't use webscript with ticket

nm_santos
Champ in-the-making
Champ in-the-making
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=606b17d58d32ce...
http://localhost:8080/alfresco/service/javadir/Company%20Home?verbose=true?alf_ticket=TICKET_606b17d...
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.
2 REPLIES 2

abarisone
Star Contributor
Star Contributor
Hi,
The correct URL is the second one since alf_ticket is always in the form TICKET_<hex sequence>
I think you missed the & into the querystring
try with
http://localhost:8080/alfresco/service/javadir/Company%20Home?verbose=true&alf_ticket=TICKET_606b17d...
Regards,
Andrea

nm_santos
Champ in-the-making
Champ in-the-making
Hi,
The correct URL is the second one since alf_ticket is always in the form TICKET_<hex sequence>
I think you missed the & into the querystring
try with
http://localhost:8080/alfresco/service/javadir/Company%20Home?verbose=true&alf_ticket=TICKET_606b17d...
Regards,
Andrea

Yes!

Thank you Smiley Happy

I don't know why I typed an "?" mark!

Thanks,
Nuno.