Not able to create site programmatically

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2016 01:08 AM
Hi ,
I trying to create a site in alfresco share using a webscript in java and this i am doing with the help of below code:
HttpClient client = new HttpClient(); PostMethod httpPost = new PostMethod ("http://localhost:8080/share/service/modules/create-site?authority="+username+"&alf_ticket="+alf_tkt); JSONObject site = new JSONObject(); try { site.put("shortName", "java_test"); site.put("Visiblity", "Public"); site.put("sitePreset", "site-dashboard"); site.put("title", "java_test"); site.put("description", "test"); httpPost.setDoAuthentication(true); httpPost.setRequestHeader("Content-Type", "application/json"); httpPost.setRequestEntity( new StringRequestEntity(site.toString(), "application/json", "UTF-8")); int status1 = client.executeMethod(httpPost); if (status1 != HttpStatus.SC_OK) { System.err.println("Method failed: " + httpPost.getStatusLine()); } } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }
It is giving me the error as HTTP/1.1 401 Unauthorized.
Please help me in this.
Regards,
Nancy
Labels:
- Labels:
-
Archive
11 REPLIES 11

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2016 05:33 AM
Niketa, I am using SSO authentication in alfresco and when i am using share/page/dologin with that it is giving me 302 error.
Regards,
Nancy
Regards,
Nancy

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2016 04:44 AM
i am able to get jsession id and my script is also working giving no exception but in alfresco share site is not created.
Can anyone tell me where it is breaking?
Regards
Nancy
Can anyone tell me where it is breaking?
Regards
Nancy
