cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to create site programmatically

nancyaggarwal
Champ in-the-making
Champ in-the-making

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

11 REPLIES 11

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

nancyaggarwal
Champ in-the-making
Champ in-the-making
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