As Rob very correctly mentioned, REST API doesn't have complete support for folders. But using the old /_vti_bin/listdata.svc
, you can create a list item and add it inside a folder. For that, you need to set the Path
property as server-relative url
Try with below code:
$(document).ready(function () {
function createListItem(webUrl,listName, itemProperties, success, failure) {
$.ajax({
url: webUrl + "/_vti_bin/listdata.svc/" + listName,
type: "POST",
processData: false,
contentType: "application/json;odata=verbose",
data: JSON.stringify(itemProperties),
headers: {
"Accept": "application/json;odata=verbose"
},
success: function (data) {
success(data.d);
},
error: function (data) {
failure(data.responseJSON.error);
}
});
}
//Usage: create list item
var itemProperties = {
'Title': 'Test item inside folder',
//server relative path
'Path': '/sites/Test/Lists/Test/FolderName'
};
createListItem('https://tenantname.sharepoint.com/sites/Test/','Test',itemProperties,function(item){
console.log('TestRESTAPI' + item.Title + ' has been created');
},
function(error){
console.log(JSON.stringify(error));
}
);
});
Have tested the above code in SPO and its working fine.


Your second option would be to create a list item normally , then get its FileRef and FileDirRef
properties and after that move it inside the folder using the MoveTo
command. This will involve 3 REST API calls
Vadim, one of SP.SE's top contributor has implemented it.
Check this link - Add ListItem to List Folder using Rest-Api