I thought I did: Your custom code needs to handle authentication against APS, i.e. manage login / SSO and session. As I mentioned earler, you should use ReST / HTTP client framework (not use the raw Java URL connection handling), which typically already provide some utilities i.e. for HTTP BASIC authentication and session handling, as well as JSON to Java mapping.
as you mentioned I updated my code but after changing I am still facing same errors and I am new to alfresco so I don't know how to manage login/SSO and session through my code against APS. My updated code is below:
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost(
"http://23.22.110.20:9090/activiti-app/api/enterprise/process-instances");
StringEntity input = new StringEntity("{\"processDefinitionId\":\"adhoctask:1:13\"}");
input.setContentType("application/json");
postRequest.setEntity(input);
HttpResponse response = httpClient.execute(postRequest);
if (response.getStatusLine().getStatusCode() != 201) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatusLine().getStatusCode());
}
BufferedReader br = new BufferedReader(
new InputStreamReader((response.getEntity().getContent())));
String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
}
httpClient.getConnectionManager().shutdown();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Could you please address me how to fix those errors?
You are still not handling any sort of authentication.... Since you are using HttpClient, I'd advise to look into its documentation on authentication. And also check the APS documentation on handling authorisation.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.