This is my Sharepoint site http://sp2k13/sites/ifsp/ and I would like to create a folder using Sharepoint RESTFul API with Java.

I have already gone through Working with folders and files with REST in sharepoint msdn.

But how to do it with Java? I think it will be possible.

  • Do you want to create folders in document library or lists?
    – Asad Refai
    May 4, 2015 at 11:44
  • @AsadRefai in lists
    – Sagar Pudi
    May 4, 2015 at 11:56
  • You need only REST solution or JavaScript Object Model is fine with you?
    – Asad Refai
    May 4, 2015 at 11:57
  • 3
    @AsadRefai I am asking for REST solution
    – Sagar Pudi
    May 4, 2015 at 13:08
  • In my experience, creating Folders using REST does not work correctly. When you create a Folder in SharePoint it actually creates the Folder and an associated List Item. It's the List Item that shows in the List View in the SharePoint UI. When you create a Folder using the REST API, it just creates the Folder. I've reported this issue on the Office 365 Dev User Voice. Feb 4, 2016 at 23:58

3 Answers 3


You can do something similar as below

String req = "http://sp2k13/sites/ifsp/_api/Web/Folders/add('LibraryName/FolderName')"
NTCredentials credentials = new NTCredentials(UserName, Password, "JAVA-MACHINE-NAME", "DOMAIN");
HttpClient httpClient = new HttpClient();
httpClient.getState().setCredentials(AuthScope.ANY, credentials);

ClientExecutor clientExecutor = new ApacheHttpClientExecutor(httpClient);
java.net.URI uri = new java.net.URI(req);
ClientRequestFactory fac = new ClientRequestFactory(clientExecutor, uri);

ClientRequest request = fac.createRequest(req);
request.header("content-type", "application/json;odata=verbose");
request.header("X-RequestDigest", digestValue);

ClientResponse<String> response = request.post(String.class);

if (response.getStatus() != 200) {
    throw new RuntimeException("Failed : HTTP error code : " +

For more information go through article http://blog.ctp.com/2012/12/21/interoperability-between-java-and-sharepoint-2013-on-premises/


JShare uses REST protocol to access to SharePoint and Office 365.

Check this create folder example


I found on the net Jshare. It's Java API for Microsoft SharePoint from Independentsoft company. There is an example of creating a directory on their site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.