As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
org.apache.commons.httpclient.HttpClient
http://localhost:8080/alfresco/service/api/login
HttpClient client = new HttpClient(); String apiurl = "http://localhost:8080/alfresco/service/api/login"; PostMethod post = new PostMethod(apiurl); JSONObject login = new JSONObject(); login.put("username", "admin"); login.put("password", "admin"); post.setDoAuthentication(true); post.setRequestHeader("Content-Type", "application/json"); post.setRequestEntity(new StringRequestEntity(login.toString(),"application/json", "UTF-8")); int status = client.executeMethod(post); String responseData = post.getResponseBodyAsString(); JSONObject response = new JSONObject(responseData); String ticket = response.getJSONObject("data").getString("ticket"); // get login ticket String apiurl = other webscript url "+"?alf_ticket="+ticket; //pass ticket as parameter in following calls PostMethod post = new PostMethod(apiurl);