As Tommy pointed out in his answer and according to 3.1.4.3 Document:
Inserting new documents to a document library involve sending a POST
request containing the contents of the document to the EntitySet
representing the document library. The protocol client MUST include
the SLUG header (as specified in RFC5023 section 9.7) whose value
is the name of the file that is being created in their POST requests.
How to create Folder via REST in SharePoint 2010 using JavaScript
function createFolder(webUrl,listName,folderName,folderPath, success, failure) {
var folderPayload = {
'ContentType': 'Folder',
'Title' : folderName,
'Path' : folderPath
};
$.ajax({
url: webUrl + "/_vti_bin/listdata.svc/" + listName,
type: "POST",
contentType: "application/json;odata=verbose",
data: JSON.stringify(folderPayload),
headers: {
"Accept": "application/json;odata=verbose",
"Slug": folderPath + "/" + folderName + "|0x0120"
},
success: function (data) {
success(data.d);
},
error: function (data) {
failure(data.responseJSON.error);
}
});
}
Examples:
1 Create root folder named Orders in the Documents library
createFolder('https://intranet.contoso.com','Documents','Orders', '/Shared Documents',function(folder){
console.log('Folder ' + folder.Name + ' has been created succesfully');
},
function(error){
console.log(JSON.stringify(error));
}
);
2 Create sub folder named 2014 under the folder Orders in the Documents library
createFolder('https://intranet.contoso.com','Documents','2014', '/Shared Documents/Orders',function(folder){
console.log('Folder ' + folder.Name + ' has been created succesfully');
},
function(error){
console.log(JSON.stringify(error));
}
);