0

How do you create a folder in document library. I got this code right now but getting error code 403 FORBIDDEN

public void createFolder(String digest) throws ClientProtocolException, IOException {
    HttpPost request = new HttpPost(
            "http://industrial-ex/sites/tifdemo/_api/Web/Folders/add('enovia/newfolder')");
    request.addHeader("Content-Type", "application/json;odata=verbose");
    request.addHeader("X-RequestDigest", digest);
    request.addHeader("Accept", "application/json;odata=verbose");
    CloseableHttpResponse response = httpClient.execute(target, request, context);
    System.out.println("STATUS CODE: " + response.getStatusLine());
}
12
  • The documentation states that a site relative url will work, strange that it does not here. Have you tried a server relative url or the method here?
    – wjervis
    Commented Feb 26, 2015 at 14:39
  • The method you mentioned Commented Feb 26, 2015 at 15:00
  • Sorry i edited the question. i get error code 403 forbidden Commented Feb 26, 2015 at 15:01
  • Oh, should've asked the obvious, do you have the authorization token?
    – wjervis
    Commented Feb 26, 2015 at 15:13
  • The Digest you mean? Commented Feb 26, 2015 at 15:14

0

Your Answer

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

Browse other questions tagged or ask your own question.