0

I am trying to check out and checking file using rest api, but getting 400 Bad Request.

Following is my code:

String urlM = "https://sharepoint.com/sites//_api/web/GetFileByServerRelativeUrl('/Shared%20Documents/Project%20Logs/My%20Cust/11111/aa/Test%20Folder/filDetails.txt')/CheckOut()";

        System.out.println("urlM    " + urlM);
        System.out.println("urlM    " + urlM);
        URL urlMkt = new URL(urlM);
        URLConnection conMkt = urlMkt.openConnection();
        HttpURLConnection httpConMkt = (HttpURLConnection) conMkt;
        httpConMkt.setDoOutput(true);
        httpConMkt.setDoInput(true);
        httpConMkt.setRequestMethod("POST");
        httpConMkt.setRequestProperty("Authorization", "Bearer " + Token);

if (httpConMkt.getResponseCode() == 200) {
            respStrMkt = "Market Folder has been created successfully. ResponseCode : " + httpConMkt.getResponseCode();
        } else {
            respStrMkt += "Error while creating Market Folder ResponseCode : " + httpConMkt.getResponseCode() + " "
                    + httpConMkt.getResponseMessage();
        }
2

1 Answer 1

0

Thanks for your response. Iam passing the token. the x-requestdigest is not required. Also I have got the solution. Instead of String urlM = "sharepoint.com/sites//_api/web/GetFileByServerRelativeUrl('/…"; i put as "String urlM = "sharepoint.com/sites//_api/web/GetFileByServerRelativeUrl('/… /(filDetails.txt')/CheckOut()"; and its working now

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.