AnsweredAssumed Answered

create new folder by web script :: POST /alfresco/s/api/site/fol

Question asked by fahad on Dec 18, 2014
Dear ALL


I want to create a new folder into my Site MySiteABC and its first folder is "REALISATIONS". Now I want to create a new folder inside REALISATIONS, but when I ran the following code I got 404 error;
{
"status" :
{
"code" : 404,
"name" : "Not Found",
"description" : "Requested resource is not available."
},

"message" : "",
"exception" : "",

"callstack" :
[

],

"server" : "Community v5.0.0 (r86473-b92) schema 8 006",
"time" : "16 déc. 2014 17:23:06"
}

Can anyone tel me what I am doing wrong?? Do we require to create MultipartRequestEntity(parts, post.getParams())) for post here in this case??

I want to run the following script POST /alfresco/s/api/site/folder/{site}/{container}

public static void makeDirectory( String host, int port, String login, String password, String filepath) throws Exception {

String site ="MySiteABC";

String container= "REALISATIONS";



String url1 = "http://159.84.130.209/alfresco/s/api/site/folder/%7B'+site+'%7D/%7B'+container+'%7D";

System.out.println(" url is ==" + url1 );

HttpClient client = new HttpClient();

client.getState().setCredentials(
new AuthScope(host, 80),

new UsernamePasswordCredentials(login, password));
PostMethod post = new PostMethod(url1);


Part[] parts =
{

new StringPart( "name", "bernard34"),
new StringPart( "type", "cm:folder")


};

try
{

post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));



post.setDoAuthentication(true);//



int status = client.executeMethod(post);

System.out.println(post.getResponseBodyAsString());





}
catch(Exception e)
{
e.printStackTrace();
}


post.releaseConnection();

}

any help would be encouraged.

Outcomes