0

How to create a folder in Sharepoint document library using java code and NTLM authentication? I am able to create a file but not folder.

0

try below code,

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);
httpClient.getParams().setAuthenticationPreemptive(true);

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);
request.accept("application/json;odata=verbose");

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

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

Use the below links for more information,

  1. How to create a folder in Sharepoint using Java and RESTFul API?

  2. https://www.example-code.com/java/sharepoint_create_folder.asp

  3. https://stackoverflow.com/questions/1630824/sharepoint-how-to-create-a-folder-in-a-document-library-please-using-web-servic

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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