public ActionResult CreateSharePointFolder(string siteUrl, string libraryName, string folderName) { if (String.IsNullOrWhiteSpace(siteUrl) || String.IsNullOrWhiteSpace(libraryName) || String.IsNullOrWhiteSpace(folderName)) { var failResult = new { error = "Cannot create SharePoint folder. Site url, Library name and Folder name are required" }; return(new ObjectResult <object>(failResult)); } string errorMessage; var success = false; using (var clientContext = GetClientContext(siteUrl)) { success = SPHelper.CreateSharePointFolder(clientContext, libraryName, folderName, out errorMessage); } var result = new { success = success, error = errorMessage }; return(new ObjectResult <object>(result)); }