I want to create new Folder on my Site, but it give me this error:

Unexpected response from server. The status code of response is '400'. The status text of response is 'Bad Request'.

  • Can you provide a code you are using?
    – Martin Dub
    Sep 9, 2021 at 7:45

2 Answers 2


The error code means this, so in your code might be a syntax error.

When I did the research for your question, I found out MSFT already patched those errors, see here.

Below I found good example on how to create a folder:

//HTML - function calling
<button type="button" onclick="createFolder('/sites/SPConnect/Shared Documents', 'folder2')"> Add Folder </button>

//JS - function to create a folder
function createFolder(folderPath, newFolderName) {
    var folderEndpoint = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getfolderbyserverrelativeurl('" + folderPath + "')/folders/add(url=\'" + newFolderName + "\')";

        url: folderEndpoint,
        type: "POST",
        headers: {
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "accept": "application/json;odata=verbose",
            "content-type": "application/json;odata=verbose"
        success: function (data) {
            console.log("Folder created successfully");
        error: function (error) {

Check the syntax and your code should work.


How many documents in this library?

Does the issue exists in other libraries? Try to create folder and compare the result.

If the issue just exists in one library, check whether the library has unique permission, make sure the users has at least contribute permission on the library.

And go to library settings -> Advanced settings -> In the Folder section, click the “Yes” option to make the “New Folder” menu item available.

Or you could try to create a folder by using PowerShell.


PowerShell to Create a Folder in Document Library

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.